auth.php
<?php
// start session
session_start();
// convert username and password from _POST or _SESSION
if($_POST){
$_SESSION['username']=$_POST['username'];
$_SESSION['password']=$_POST['password'];
}
// query for a user/pass match
$result = mysql_query("SELECT * FROM users WHERE username='" . $_SESSION['username'] . "' and password='" . $_SESSION['password'] . "'");
// retrieve number of rows resulted
$user = mysql_num_rows($result);
// print login form and exit if failed.
if($user < 1){
echo " Please login";
?>
logout.php
<?php
// logout.php
// you must start session before destroying it
session_start();
session_unset();
session_destroy();
//}
//echo "You have been successfully logged out.
echo " logged. Out.";
?>
The codes above working fine, after I log out, if I paste the direct link to the admin.php, it won't go. But the problem is, when I log out, if I press the back button on the browser (firefox), it will back to admin.php.*
Please help.
* echo part in both codes was temporarily changed to save page.