having some difficulty with this, here is the setup.
page1. html form with username and pass input.
page2. validate username and pass with sql table have link to page 3
page3. check login status.
Now for page 2 i used:
<?
$pass = md5($pass);
include 'db.php';
$sql = "select * from staff where username='$uname' and password='$pass'";
$result = mysql_query($sql);
if(mysql_num_rows($result)!=0)
{ echo "we have a match";
$_SESSION['loggedin']=true;
}
else
{
echo "error";
}
?>
And for page3 i used:
<?
session_start();
if ($_SESSION['loggedin'])
{
echo 'you are logged in ...';
}
else
{
echo 'error';
}
?>
But if i remove the $_SESSION['loggedin']=true; from page 2, page 3 gives me a "you are logged in" message, is there any other simpler way of doing this or am i doing something wrong? Also is there a way of setting an idle time, so say of there isnt any activity for say 2mins then the user is logged out automatically and taken to page1.
Many thanks
ceanth