maybe you need to register the variable as a session variable. Try: (what a mess)
why don't?
$showform=true;
if(isset($_POST["email"] && isset($_POST['password'])) (
1. check if the login name and password are right
1.1 register variables
1.2 showform=false;
}
if ($showform) {
show the form again
}
this way you will have no need to write the form twice! i think is much clearer. Anyway, what you are doing is this:
if (sql_num_rows($result)== 0) {
register variables
logged=true
show the form again
}
so, if there is no result, you log the user, then show the form and submit it, and just when it returns you set logged=false again...
try this
if (sql_num_rows($result)) {
session_register ('whatever'); // i don't know if this is really necessary
$_SESSION['whatever']=whatever;
}
Just another thing...
You have written
if ($_SESSION['logged']=true) {
i'm logged
}
notice the condition above is always true, whatever $_COOKIE['logged'] contains...
Try
if ($_SESSION['logged']==true) // or just
if ($_SESSION['logged'])