I'm creating form in PHP for reset User password.
When user send request for reset it send link to the Mail for reset password.
In the link is domain.com/index.php?link=reset-password&code=1_Xzpq+/F64xwZ/oQ/U4TkTQ==
1 = User_id
Xzpq.. = User password hash (Salted)
I need explode UserID and PasswordHash to the variables
My code:
function isValidPasswordResetToken($string) {
global $sqlConnect;
//$string_exp = explode('_', $string);
list($user_id, $password) = explode('_', $string);
//$user_id = $string_exp[0];
//$password = $string_exp[1];
if (empty($user_id) or !is_numeric($user_id) or $user_id < 1) {
return false;
}
if (empty($password)) {
return false;
}
$query = mysqli_query($sqlConnect, " SELECT COUNT(`user_id`) FROM " . USERS . " WHERE `user_id` = {$user_id} AND `password` = '{$password}' AND `active` = '1' ");
return (Sql_Result($query, 0) == 1) ? true : false;
}
It works good, BUT.. When PasswordHash is like Xzpq+/F64xwZ/oQ/U4TkTQ==
(in Hash is '+' character) it not working..
When PasswordHash is m7c7Tn67QpI2eI1jLdqOEg==
it works without problem..
It is a chance to do this some other way, which would support all the characters? Or what am I doing wrong?
Thank you for every answer.