Md5 verification for login passwords of thinkphp members. When a member registers, the password md5 is encrypted and saved to the database. now, after the member logs on to the database, how can he write the md5 password? Why is it different when I retrieve the form md5 and query it in the database? my code is class & nbsp; AdminAction & nbsp; extends & nbsp; Action {& nbsp; md5 verification for login passwords of thinkphp members.
When a member registers, the password md5 is encrypted and saved to the database. now, after the member logs on to the database, how can he write the md5 password? Why is it different when I retrieve the form md5 and query it in the database? my code is
class AdminAction extends Action{
function index(){
if(isset($_POST['username'])){
if(isset($_POST['username'])&&isset($_POST['password'])){
$secure_code = C('SECURE_CODE');
$userpassword=md5($secure_code.md5($_POST["password"]));
$db=M();
$select=$db->query("select * from developers where username=".$_POST['username']." and password=".$userpassword."");
echo $db->getLastSql();exit;
What should I do? Share:
------ Solution --------------------
If you have posted three posts for three consecutive days for a login function, you cannot think about it by yourself and find out if there is any solution.
------ Solution --------------------
md5($secure_code.md5($_POST["password"]));
This is to add something to the original password. during verification, you cannot add it.
------ Solution --------------------
1: $ userpassword = md5 ($ secure_code.md5 ($ _ POST ["password"]); why does MD5 need to be encrypted twice?
2: Now that the last statement is printed, will the MD5 of the password be compared with that encrypted in the database with the eyes?
------ Solution --------------------
Reference:
md5($secure_code.md5($_POST["password"]));
This is to add something to the original password. during verification, you cannot add it.
+ 1! How did you encrypt it before you put it into the database? how did you encrypt it during verification! Copy the statement,
------ Solution --------------------
Are you sure the encryption method is the same during insertion and query?