User Login questions please help us
$username = Htmlspecialchars ($_post[' username ');
$password = MD5 ($_post[' password ');
Include database connection file
Include (' conn.php ');
Check that the username and password are correct
$check _query = mysql_query ("Select ' uid ' from ' user ' WHERE ' username ' = ' $username ' and ' password ' = ' $password ' LIMIT 1 ');
if ($result = mysql_fetch_array ($check _query)) {
Login successful
$_session[' username '] = $username;
echo "OK";
Exit
} else {
Exit (' Login failed! Click here to return to retry ');
}
?>
Please look at the code where the error occurred in the database has entered the user name, but still login failed
But if the ' password ' = ' $password ' is removed, the user name can be queried, but the password can be entered in any case.
------Solution--------------------
$result = mysql_query ("Select UID from user WHERE username ' = ' $username ' and ' password ' = ' $password '");
echo mysql_num_rows ($result). "
"///See if the result is 1, if not, then your username or password has a problem
if ($mysql _num_rows ($result) ==1) {
$row =mysql_fetch_array ($result));
$_session[' username '] = $row [' username '];
echo "Login Successful";
}else{
echo "Login Failed";
}