when i run this script it always comes up my error message 'incorrect login...'. i cant see anything wrong with it, can you?
here's my login page
<?
print "<B>Login<B>";
print "<P>";
print "<FORM action=login_authenticate.php METHOD=POST>";
print "Username:";
print "<INPUT TYPE=TEXT NAME=username>";
print "<P>";
print "Password:";
print "<INPUT TYPE=PASSWORD NAME=password>";
print "<P>";
print "<INPUT TYPE=SUBMIT VALUE=SUBMIT NAME=login>";
print "</FORM>";
?>
the login page has no problems, but my authenticate page does.
<?
//convert the field values to simple variables
//add slashes to the username and md5() the password
$user = $_REQUEST['username'];
$pass = md5($_REQUEST['password']);
//set the database connection variables
$dbHost = "localhost";
$dbUser = "root";
$dbDatabase = "logins";
//connet to the database
$db = mysql_connect("$dbHost", "$dbUser");
mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database.");
$result=mysql_query("select * from login where user='$user' AND pass='$pass'", $db);
//check that at least one row was returned
$rowCheck = mysql_num_rows($result);
if($rowCheck > 0){
while($row = mysql_fetch_array($result)){
//start the session and register a variable
session_start();
session_register($user);
//successful login code will go here...
echo 'Success!';
}
}
else {
//if nothing is returned by the query, unsuccessful login code goes here...
echo 'Incorrect login name or password. Please try again.';
}
?>
my DB is called logins and my table is called login