I have made a login screen from kevins tutorial. The sign up works fine, but when i login i get the access denied screen, even with a correct username and password. If someone could take a look at the code i used below and tell me what i did wrong i would greately appreciate it.

accesscontrol.php

<?php //accesscontrol.php

include("common.php");
include("db.php");

session_start();

if(!isset($uid)) {
?>

<html>
<head>
<title>Please Log In For Access</title>
</head>
<body>
<h1>Login Required</h1>
<p>You must log in to access this area of the site. If you are not a registered
user, <a href="signup.php">click here</a> to sign up for instant access!</p>
<p><form method="post" action="<?=$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_register("uid");
session_register("pwd");

dbconnect("sessions");
$sql = "SELECT * FROM user WHERE
userid = 'uid' AND password = 'pwd'";
$result = mysql_query($sql);
if(!$result) {
error("A database error has occured while checking your ".
"login details.\\nIf this error persists, please ".
"contact trhynard@aol.com.");
}
if (mysql_num_rows($result) == 0) {
session_unregister("uid");
session_unregister("pwd");
?>
<html>
<head>
<title>Access Denied</title>
</head>
<body>
<h1>Access Denied</h1>
<p>Your user ID or password were incorrect, or you are not a registered user on this site.
To try logging in again please click <a href="<?=$php_self?>">here</a>.
To register for instant access, please click <a href="signup.php">here</a>.</p>
</body>
</html>
<?php
exit;
}
$username = mysql_result($result,0,"fullname");
?>