I had a database field which stores passwords like this:
TeacherPassword
j.lu01
pesci02
cricket01
Now I have a textbox where the user enters in a password and if it matches with one of the rows then it navigates to the next page. Below is the code where it checks for the password.
$teacherpassword = (isset($_POST['teacherpassword'])) ? $_POST['teacherpassword'] : '';
if (isset($_POST['submit'])) {
// don't use $mysqli->prepare here
$query = "SELECT * FROM Teacher WHERE TeacherPassword = ? LIMIT 1";
// prepare query
$stmt=$mysqli->prepare($query);
// You only need to call bind_param once
$stmt->bind_param("s",$teacherpassword);
// execute query
$stmt->execute();
// get result and assign variables (prefix with db)
$stmt->bind_result($dbTeacherPassword);
But what I have done is that I have updated the password field so that the field does not show the passwrod as a string, but as a bunch of characters so that their passwords are safe. Below is the update I did:
UPDATE Teacher
SET TeacherPassword = Password(TeacherPassword);
This causes the password field to look like this now:
TeacherPassword
*6FF132E0666AC8462BC
*FCF5F8CE105D0748315
*FD4FA4B60EEF1E24050
So what my question is that in my MYsqli code, how do I get the string password entered in the textbox j.lu01
to match with its hash password in the database row *6FF132E0666AC8462BC
?