php, login script
<p>I am new in php and I am trying to write a registration script. My problem is that when I try to sign in  and I can't see the user`s menu. Maybe the problem is with the sessions and cookies but I can't find it. Here is part of my code:</p>

<p>config.php</p>

<pre><code>&lt;?php
  oB_start(); 
  $con = mysql_connect("localhost","root","123");
  if (!$con) {
    die('Could not connect: ' . mysql_error());
  }
  mysql_select_db("9gag", $con);
  $logged = MYSQL_QUERY("SELECT * from users WHERE id='$_COOKIE[id]' AND password = '$_COOKIE[password]'"); 
  $logged = mysql_fetch_array($logged); 
?&gt;
</code></pre>

<p>login.php</p>

<pre><code>&lt;?php 
  oB_start(); 
  include("config.php"); 
  if (!$logged[username]) { 
    if (!$_POST[login]) { 
      echo("&lt;center&gt;&lt;form method=\"POST\"&gt; 
            &lt;table&gt; 
            &lt;tr&gt; 
            &lt;td align=\"right\"&gt; 
            User: &lt;input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"&gt; 
            &lt;/td&gt; 
            &lt;/tr&gt; 
            &lt;tr&gt; 
            &lt;td align=\"right\"&gt; 
            Password: &lt;input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\"&gt; 
            &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt; 
            &lt;td align=\"center\"&gt; 
            &lt;input type=\"submit\" name=\"login\" value=\"Sign in\"&gt; 
            &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt; 
            &lt;td align=\"center\"&gt; 
            &lt;a href=\"register.php\"&gt;Sign up&lt;/a&gt; 
            &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/form&gt;&lt;/center&gt;"); 
    } 
    if ($_POST[login]) { 
        $username = $_POST[username]; 
        $password = $_POST[password]; 
        $info = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); 

        $data = mysql_fetch_array($info); 
        if($data['PASSWORD'] != $password) { 
            echo "Wrong username or password!"; 
        }else{ 
            $query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); 
            $user = mysql_fetch_array($query); 
            setcookie("id", $user['ID'],time()+(60*60*24*5), "/", ""); 
            setcookie("password", $user['PASSWORD'],time()+(60*60*24*5), "/", ""); 
        } 
    } 
} 
else { 
    echo ("&lt;center&gt;Welcome &lt;b&gt;$logged[username]&lt;/b&gt;&lt;br /&gt;&lt;/center&gt; 
                &lt;a href=\"editprofile.php\"&gt;Profile&lt;/a&gt;&lt;br /&gt; 
                &lt;a href=\"logout.php\"&gt;Log out&lt;/a&gt;"); 
} 
?&gt;
</code></pre>
