Yes Im new and my techniques are probably in doubt, please advise me.
I Have a login page. When they successfully login session variables are created. The login page then shows an include greeting them and showing links. When they click on the links and move around they are in the session. When they hit logout they are again at the login page.
When I hit backspace and back up through the pages of the links the session variables are empty so the page does not show. When they back up all the way to the log in page they get the "Warning Page has expired". Refreshing this page amazingly apparently relogs them in even though all the session variables should be destroyed. Its like the login page is keeping the variables.
What am I doing wrong? How do you deal with the "Warning Page has expired" crap? Please clue me in. Im gonna include my login code here and you all can tell me how less than perfect it is. Thanks You.
<?
include("hold/sess.php");
print $loggedin;
print "here";
print $usr;
print $pswd;
?>
<head>
<title>Coleman Cable InfoXpress Login</title>
</head>
<body><center>
<?
require("hold/topbar2.htm");
if (!isset($usr)&&!isset($pswd)&&($loggedin!='y')){
//user needs to enter name password
?>
<h3>Please enter Username and Password to Log in to InfoXpress</h3>
<? print "<form action=\"$PHP_SELF\" method=\"POST\">\n";
//<form method=post action="index.php">?>
<p><strong> Username:</strong><br>
<input type="text" name="usr" size=12 maxlength=12></p>
<p><strong> Password:</strong><br>
<input type="text" name="pswd" size=12 maxlength=12></p>
<p><input type="SUBMIT" name="submit" Value="Log In"></p>
</form>
<?
}
else
{
// connect to db
include ("hold/db.inc");
// query user file for match
$query = "select * from col_user where u_uname='$usr' and u_pswd='$pswd'";
$result = mysql_query( $query );
if(!$result)
{
echo "Query failed";
exit;
}
$num_rows = mysql_num_rows( $result );
// must be found and usr and password can not be blank
if (($num_rows > 0))
{
// user password correct
// register session variables
//include("hold/regsess.php");
$myrow = mysql_fetch_array($result);
$repname = $myrow["u_repname"];
$repnum = $myrow["u_repnum"];
$reptype = $myrow["u_reptype"];
// indicate successfully logged in
$loggedin = 'y';
$usr = '';
$pswd = '';
$result = '';
echo "<br>";
include("nav/navbar.htm");
echo "<br>";echo "<br>";
echo "Access Granted!";
echo "<br>";echo "<br>";
echo "Welcome $repname";
}
else
{
echo "<br>";echo "<br>";
echo "Login Has Not Found A Match; Entry Rejected";
}
}
?>
</center>
</body>