I'm busy creating a login script and now have the following;
It detects the username and can match it without a worry but seems to have problems matching the password too. My password is put into the mysql field md5 encrypted. Can anyone see anything wrong with the code above?
Thanks.
Code:
$user_pass_check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'") or die(mysql_error());
//Gives error if user dosen't exist
$check_row = mysql_num_rows($user_pass_check);
if ($check_row == 0) {
die('That user does not exist <a href=register.php>Click Here to Register</a>');
}
while($info = mysql_fetch_array($user_pass_check))
{
$_POST['password'] = stripslashes($_POST['password']);
$info['pass'] = stripslashes($info['pass']);
$_POST['password'] = md5($_POST['password']);
//gives error if the password is wrong
if ($_POST['password'] != $info['pass']) {
die('Incorrect password, please try again.');
}
It detects the username and can match it without a worry but seems to have problems matching the password too. My password is put into the mysql field md5 encrypted. Can anyone see anything wrong with the code above?
Thanks.