I used MD5 in my database. I use UserKey instead off a password as I can have more than 1 word. A sentance even using any cahrtecter $%^&£@!
That is why I used md5. Passord is the same as userkey. I even tested the sql and got one record.
My record is found as UserN = 'a39e9eea66930fe0050d56a28bafab72' and UserKey = '44f1fa64d8974c18bcb9182286d3e2aa'
function LogMeX2($name,$pwd1)
{
$Name = md5($name);
$Pwd1 = md5($pwd1);
$sql = "SELECT User, UserKey FROM LIBusersX WHERE UserKey = '$Pwd1' AND UserN = '$Name'";
echo $sql; // Returns 1 record Name = 'a39e9eea66930fe0050d56a28bafab72' UserKey is the Password = '44f1fa64d8974c18bcb9182286d3e2aa'
$pdo = connectDB();
$stmt = $pdo->prepare($sql);
$stmt->execute([$Name]);
// fetch/test if a row was found, i.e. the username was found
if(!$row = $stmt->fetch())
{
// username not found
return false;
}
// username found, test password
if(!password_verify($Pwd1,$row['UserKey']))
{
// passwrod didn't match
return false;
}
// username and password matched, return user id
return $row['User'];
}