Can somebody please tell me why this code is not working? The auth window comes up the first time I visit the page, but after I logout, when I go back, it does not pop up the window again. It still thinks I am logged in.
if($_GET['logout'] == "1") {
echo "You have been logged out, {$PHP_AUTH_USER}.";
unset($PHP_AUTH_USER);
unset($PHP_AUTH_PW);
//header("Location: [url]http://domain.com/[/url]");
echo "<BR><BR><A HREF=\"http://domain.com/\">Return To Intranet Homepage</A>";
exit;
}
if(!isset($PHP_AUTH_USER)) {
HEADER("WWW-authenticate: basic realm=\"restricted area\"");
HEADER( "HTTP/1.0 401 Unauthorized");
unset($PHP_AUTH_USER);
unset($PHP_AUTH_PW);
echo "You failed to provide the correct password...\n";
exit;
} else {
mysql_select_db("users");
$username = strtolower($PHP_AUTH_USER);
$result = mysql_query("SELECT * FROM users WHERE username = '$username'");
$row = mysql_fetch_array($result) or die(mysql_error());
$level=$row['level'];
$password=$row['password'];
if ($PHP_AUTH_PW != $password) {
HEADER( "WWW-authenticate: basic realm=\"restricted area\"");
HEADER( "HTTP/1.0 401 Unauthorized");
echo "You failed to provide the correct password...\n";
exit;
}
}
?>
And, then at the bottom of the page I have this
<A HREF="admin.php?logout=1">Logout</A>
It tells me that I have logged out, but when I go back to the page, it does not bring up the window.
Thanks,
Jeff