Thinkphp member logon password verification md5 problems

Source: Internet
Author: User
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?

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.