Hi!,
I know this question has been posted by so many people but I seem to have a problem with my website. I have an admin section of the site, the code for logging works the only problem is that I want to maintain a session across all the pages of the admin section. This is the code for login.php
session_start();
include("../html/config.php");
$username=$_POST['username'];
$password=$_POST['password'];
session_register("username");
session_register("password");
$sql = mysql_query("SELECT password FROM admin WHERE username = '$username'");
$fetch_em = mysql_fetch_array($sql);
$numrows = mysql_num_rows($sql);
if($numrows != "0" & $password == $fetch_em["password"]) {
$valid_user = 1;
header("Location:admin.php");
}
else {
$valid_user = 0;
header("Location:index.php");
}
?>
I want 2 be able to check that the session of the username isnt empty if it is then u shudnt be able to access any section of the admin.
How can I check the session on every page?