I have a script for a log in that works on another database and site, but doesn't seem to agree with the one I'm trying to get it set up on. Basically what it is doing is not recognizing either the username or password, thus not letting me past the login page. Can anyone tell me what can be causing this problem and what I need to do to fix it? Here's the code:
<?php
$username = $POST['username'];
$password = $POST['password'];
if(isset($_POST['login']))
{
require("dbheader.php");
$person = mysql_query("SELECT * FROM cafeusers WHERE username = $username AND password = MD5('$password')");
if(mysql_num_rows($person) > 0)
{
session_start();
$_SESSION['userid'] = $person['userid'];
header("location: home.php");
}
else
{
$error = true;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="style2.css" rel="stylesheet" type="text/css" />
<title>Login Page</title>
</head>
<body>
<div class="login">
<?php
if($error == true)
{
echo("<p>Username or password invalid.</p>");
}
?>
<form method="post" action="<?=$_SERVER['PHP_SELF'];?>">
<p>Username: <input type="text" name="username" value="<?=$_POST['username'];?>" /></p>
<p>Password: <input type="password" name="password" /></p>
<p><input type="submit" name="login" value="Login" /></p>
</form>
</div>
</body>
</html>