+ 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
2 odpowiedzi
+ 3
please can you explain more
+ 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.