how to change a password columm in my database | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

how to change a password columm in my database

<?php if (isset($_POST['submit'])) { include_once 'dbh.inc.php'; $hashedPwd = password_hash($newpwd, PASSWORD_DEFAULT); $sql = "UPDATE users SET user_pwd = $hashedPwd WHERE user_id = $_POST['email']"; } if (mysqli_query($conn, $sql)) { echo "Record updated successfully"; } else { echo "Error updating record: " . mysqli_error($conn); } mysqli_close($conn); ?> note that $newpwd is the new password the person has just typed in the html form

6th Mar 2018, 6:56 AM
Franklyn Omeben
Franklyn Omeben - avatar
2 Answers
+ 3
please can you explain more
6th Mar 2018, 1:03 PM
Franklyn Omeben
Franklyn Omeben - avatar
+ 1
Firstly you will need to get the new password value after the form submit. SO use, $newPassword = $_GET["your-password-input-id-here"]; Then use MD5 to hash the new password. $hashedPassword = md5($newPassword); And that should do the trick.
6th Mar 2018, 9:06 AM
ihateonions