can someone please insert a hashing algorithm for the password in this php code
ID: 3814592 • Letter: C
Question
can someone please insert a hashing algorithm for the password in this php code for a website account registration using a email?
require("connect.php");
if($_POST['submit'])
{
$login = $_POST['login'];
$password = $_POST['password'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$dob = $_POST['dob'];
$gender = $_POST['gender'];
$specialisation = $_POST['specialisation'];
$clinic = $_POST['clinic'];
$address = $_POST['address'];
$city = $_POST['city'];
mysql_query("insert into dusers values ('$login', '$password', '$firstname', '$lastname', '$dob', '$gender', '$specialisation', '$clinic', '$address', '$city')") or die(mysql_error("Unable to insert Values"));
echo "
Registration Successful.
";
}
echo "";
//}
?>
Explanation / Answer
Ans: Im suggesting four ways for password hashing for your code. you can insert any of them for password hashing.Thank you.
1..$hashed_password = password_hash($password, PASSWORD_DEFAULT); //
2..$hash = password_hash($plainTextPassword, PASSWORD_DEFAULT); //
3..,mysqli_real_escapes
$password_string = mysqli_real_escape_string($_POST["password"]); //
4..crypt::
$hash = crypt($password);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.