I have a problem with my request.
in database ( userid, code, timestamp)
I want to check in this code if there is a user ID and the corresponding code, but which has been inserted for less than one day, otherwise the message "link expired" will be displayed
My code works well without this line TIMESTAMPDIFF(DAY, CURTIME(), timestamp) < 1").
Nothing is returned at the moment with a timestamp condition
"select userid, code from password_reset where userid=? and code=? and TIMESTAMPDIFF(DAY, CURTIME(), timestamp) < 1"
Is there some problems in this code? Basically, my idea is: if the timestamp has more than one day, return an error to the user.
my script (the problem is only the timestamp condition in the request)
if (checkBd ($sql, $db, $user, $codePass)){
$user = (int)mysqli_real_escape_string($db, $userid);
$codePass = mysqli_real_escape_string($db, $_GET['code']);
($sql = $db->prepare("select userid, code from password_reset where userid=? and code=? and TIMESTAMPDIFF(DAY, CURTIME(), timestamp) < 1"));
$sql->bind_param('ss', $user, $codePass);
$sql->execute();
$sql->bind_result($user, $codePass);
if ($sql->fetch()) {
$_SESSION['u_name']= sha1($user);
header("location: updatePass.php");
return true;
}
}
$sql->close();
$db->close();