Mysql_query error. the username and password in my database are both MD5 encrypted. & lt ;? Phpsession_start (); require_once '../data/config. inc. php'; // Obtain the account password POST submit if (isset ($ _ POST [& q mysql_query error, solve
In my database, both username and password are MD5 encrypted.
Session_start ();
Require_once '../data/config. inc. php ';
// Get account password POST submit
If (isset ($ _ POST ["username"]) {
$ Username = mysql_real_escape_string ($ _ POST ["username"]);
} Else {
$ Username = "";
}
If (isset ($ _ POST ["password"]) {
$ Password = mysql_real_escape_string ($ _ POST ["password"]);
} Else {
$ Password = "";
}
If (empty ($ username) | empty ($ password )){
Exit ("script" alert ('The user name or password cannot be blank! '); Window. history. go (-1) script ");
}
$ SQL = "select * from admin where username = '". md5 ($ username). "' and password = '". md5 ($ password )."'";
// Verify
Echo $ SQL;
$ Re = mysql_query ($ SQL );
Print_r (mysql_fetch_array ($ re ));
Echo $ re;
If (mysql_query ($ SQL )){
Echo "OK ";
}
Else {
Exit ("script" alert ('The user name or password is incorrect! '); Window. history. go (-1) script ");
}
?>
Everything else is correct, and the SQL statement is correct. Therefore, where should the problem be in mysql_query? How should I get it? should I enter the correct password or be wrong!
------ Solution --------------------
Print it
Echo $ SQL; content,
Check whether the md5 value is exactly the same as that in the database. Maybe your md5 function is faulty, or an incorrect result is returned.
Username = '". md5 ($ username)."' and password = '". md5 ($ password )."'";
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.