Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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);

Dr Jack
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote