search

Home  >  Q&A  >  body text

How to use password_hash algorithm

I have been studying the use of password_hash to process passwords into the database these days but I don’t know how to use it to process passwords entering the database
MD5 can be executed directly on the database statement:

$query = "INSERT INTO  member(urs_name,password,rt_time) VALUES ('{$_POST['urs_name']}',md5('{$_POST['password']}'))";

But password_hash cannot Execute directly on the MYSQL statement like this:

$query = "INSERT INTO  member(urs_name,password,rt_time) VALUES ('{$_POST['urs_name']}',password_hash('{$_POST['password']}')";

Will execute and report an error. How can password_hash be linked with the database?

镜花水月镜花水月2730 days ago1177

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-09-22 09:01:05

    $query = "INSERT INTO  member(urs_name,password,rt_time) VALUES ('".$_POST['urs_name']."','".password_hash($_POST['password'])."')";


    reply
    0
  • Cancelreply