i have an accesscontrol.php file that i include on pages that have restricted access.... it uses sessions to see if the user has permission to access the page.... everything works fine, in that it recognizes the proper user/pass, and it remembers the user for future sessions on restricted pages.... the problem i am having is im getting two errors about the same thing
the two errors are:
Notice: Undefined index: uid (line 14) and
Notice: Undefined index: pwd (line 22)
the errors are referring to the $uid and $pwd variables, any help with this would be greatly appreciated
<?php // accesscontrol.php
include("other.inc");
session_start();
$connection = mysql_connect($host,$user,$password) or die ("couldn’t connect to server");
$db = mysql_select_db($database,$connection) or die ("Couldn’t select database.");
if (isset($POST['uid']))
{
$uid = $POST['uid'];
}
else
{
$uid = $SESSION['uid'];
}
if (isset($POST['pwd']))
{
$pwd = $POST['pwd'];
}
else
{
$pwd = $SESSION['pwd'];
}
if(!isset($uid)) {
?>
<head>
<title> Please Log In for Access </title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1> Login Required </h1>
<p>You must log in to access this area of the site.</p>
<p><form method="post" action="<?=$_SERVER['PHP_SELF']?>">
User ID: <input type="text" name="uid" size="8" /><br />
Password: <input type="password" name="pwd" SIZE="8" /><br />
<input type="submit" value="Log in" />
</form></p>
</body>
</html>
<?php
exit;
}
$SESSION['uid'] = $uid;
$SESSION['pwd'] = $pwd;
$connection = mysql_connect($host,$user,$password) or die ("couldn’t connect to server");
$db = mysql_select_db($database,$connection) or die ("Couldn’t select database.");
$sql = "SELECT * FROM admin WHERE loginName = '$uid' AND password = '$pwd'";
$result = mysql_query($sql);
if (mysql_num_rows($result) == 0) {
unset($SESSION['uid']);
unset($SESSION['pwd']);
?>
<head>
<title> Access Denied </title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1> Access Denied </h1>
<p>Your user ID or password is incorrect, or you are not a
registered user on this site. To try logging in again, click
<a href="<?=$_SERVER['PHP_SELF']?>">here</a>.</p>
</body>
</html>
<?php
exit;
}
?>