note 121974 deleted from function.password-verify by salathe
| From: | salathe@php.net | Date: | Mon, 21 Sep 2020 14:43:43 +0000 |
| Subject: | note 121974 deleted from function.password-verify by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215292@lists.php.net to get a copy of this message | ||
Note Submitter: omidbahrami1990 at gmail dot com
----
This Is The Most Secure Way To Keep Your Password Safe With PHP 7 ,
Even When Your DataBase Has Been Hacked ,
It Will Be Almost Impossible To Retrieve Your Password .
--------------------------------------------------------
--- When A User Wants To Sign Up ---
1 ---> Get Input From User Which Is The User`s Password
1 ---> Hash The Password
2 ---> Store The Hashed Password In Your DataBase
--------------------------------------------------------
<?php
$hashed_password = password_hash($_POST["password"],PASSWORD_DEFAULT);
// $_POST["password"] ---> Is The User`s Input
// $hashed_password ---> Is The Hashed Password You Can Store In Your DataBase
?>
--------------------------------------------------------
--- When A User Wants To Sign In ---
1 ---> Get Input From User Which Is The User`s Password
2 ---> Fetch The Hashed Password From Your Database
3 ---> Compare The User`s Input And The Hashed Password
--------------------------------------------------------
<?php
if(password_verify($_POST["password"],$hashed_password))
echo "Welcome";
else
echo "Wrong Password";
// $_POST["password"] ---> Is The User`s Input
// $hashed_password ---> Is The Hashed Password You Have Fetched From DataBase
?>