im working on my uni project and i stuck on password recovery. Everything is working, mail is sent, new password typed in and it goes to database. BUT problem is it goes without md5 encryption and is nicely visible in my db. How to actually encrypt it in md5. Belowe my code:
<?php
$email = $_POST["email"];
$reset_token = $_POST["reset_token"];
$new_password = $_POST["new_password"];
$connection = mysqli_connect("localhost", "root", "", "registration");
$sql = "SELECT * FROM users WHERE email = '$email'";
$result = mysqli_query($connection, $sql);
if (mysqli_num_rows($result) > 0)
{
$user = mysqli_fetch_object($result);
if ($user->reset_token == $reset_token)
{
$sql = "UPDATE users SET reset_token='', password='$new_password' WHERE email='$email'";
mysqli_query($connection, $sql);
echo "Password has been changed";
}
else
{
echo "Recovery email has been expired";
}
}
else
{
echo "Email does not exists";
}
Also as Im already asking here, how to setup token for 24hrs instead of forever. Sorry, im a bit of a newbie with all of this.
Knd regards.