I have a login page and when a user logs in correctly i have them sent to protected.php. In order to stop people from just going to protected.php, skipping the login, i used to following code: <?php include("accesscontrol.php"); ?>.
But when i do this, and someone logs in correctly, it starts to take them to the page, but all it says is: connected to website, waiting for a reply, over and over and over again. What really confuses me though is when i remove the include function at the top of protected.php, it works. when the user logs in, it takes them to the page, but they could just go there any time they wanted, without logging in. could someone please tell me why it won't ever load protected.php with the include function at the top?
<body bgcolor="#FFFFFF" text="#000000">
<h1>Login Required</h1>
<p>You must log in to access this area of the site. If you are not a registered user, please
<a href="signup.php">click here</a> to sign up for free, instant access!</p>
<p><form method=post action="<?accesscontrol.php?>">
User ID: <input type=text name=uid size=15><br>
Password: <input type=password name=pwd size=15><br>
<input type=submit value=Sign In>
</form></p>
</body>
</html>
<?php
exit;
}
dbConnect("Members");
$sql = "select * from members where username = '$uid' AND password = '$pwd'";
$result = mysql_query($sql);
if (!result) {
error("A database error occured while processing your request.\\nIf this error persists, ".
"contact trhynard@aol.com.");
}
if(mysql_num_rows($result) == 1) {
session_register("uid");
session_register("pwd");
header ("Location: protected.php");
}
elseif(mysql_num_rows($result) ==0) {
session_unregister("uid");
session_unregister("pwd");
echo("Username or password was not correct.");
}
else {
echo("An error has occured. Please try again later");
}
?>
Protected.php
<?php include("accesscontrol.php"); ?>
<html>
<head>
<title> Members-Only Page </title>
</head>
<body>
<p>Welcome <?=$uid?>! You have entered a members-only area
of the site. Don't you feel special?</p>
</body>
</html>
there can be some sort of indefinate loop in ur accesscontrol.php, not sure but it may be that u r including/calling accesscontrol.php in some of files which are included in accesscontrol.php, i.e. common.php or db.php.
There may be any other reason for that...
Bookmarks