I have my old login panel that seemed to work just fine for a long time until today. This is the code:
if(!$_SESSION['logged']) {
if(isset($_POST['name'])) {
$name = clear($_POST['name']);
$pass = clear($_POST['password']);
if (empty($name) || empty($pass)) {
echo '<p>You must fill out all the blanks.</p>';
echo '<meta http-equiv="refresh" content="1;URL=logIn.php" />';
echo '</center>';
} else {
$pass = codepass($pass);
$result = mysql_query("SELECT Count(id), ACTIVE FROM `accounts` WHERE `USERNAME` = '$name' AND `PASSWORD` = '$pass'");
$row = mysql_fetch_row($result);
if($row[0] > 0 and $row[1]==1) {
$_SESSION['logged'] = true;
$_SESSION['userid'] = $row[0];
echo '<p>You have been signed in!</p>'.$_SESSION['logged'].', '.$_SESSION['userid'];
echo '<meta http-equiv="refresh" content="1;URL=index.php" />';
} elseif($row[1]!=1) {
echo '<p>You first have to activate the account before you can sign in. If you have not received any e-mail, please contact the administrator.</p>';
echo '<meta http-equiv="refresh" content="1;URL=index.php" />';
} else {
echo '<p>Signing process cannot be completed!Please try again!</p>';
echo '<meta http-equiv="refresh" content="1;URL=logIn.php" />';
}
}
} else {
and when I was trying to sign in today, it didn't let me in. I tried to put 'echo' function to see where might be a problem. And it seems like the values are properly assigned to session, but as soon as the page changes to inform the user that he's been signed in, the session disappears with no reason. I can't see the mistake in the code. Plus the code worked, so why doesn't it this time? Can anyone point out the mistake? Thanks in advance