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?


<?php // accesscontrol.php
if(!isset($uid)) {


<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>

$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) {
header ("Location: protected.php");
elseif(mysql_num_rows($result) ==0) {
echo("Username or password was not correct.");
else {
echo("An error has occured. Please try again later");


<?php include("accesscontrol.php"); ?>
<title> Members-Only Page </title>
<p>Welcome <?=$uid?>! You have entered a members-only area
of the site. Don't you feel special?</p>

I would greatly appreciate any help!!!