Mysql_query error. the username and password in my database are both MD5 encrypted. & lt ;? Phpsession_start (); require_once .. dataconfig. inc. php; get account password POST submit if (isset ($ _ POST [& quot; username & quot;]) {$ usernam 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 )."'";