I'm using the following postgresql command to try to retrieve a record for a given email / hashed pw combination. I have the password and email stored in the table, and the query seems to successfully pull f or t for the password check, but the php script doesn't seem to be working to handle the output.
PHP:
// 2. Check Passwords
$sql = "select exists(select 1 from users where (email='".$email."') AND (pw = '".$password."'));";
echo $sql . "<br>";
$ret = pg_query($db, $sql);
if(!$ret){
echo pg_last_error($db);
exit;
}
if($ret === true){
echo "Login Successful";
}else{
$errors = $errors . "Passwords do not match. Please try again. <br>";
}
This currently outputs the sql query
select exists(select 1 from users where (email='alex@email.com') AND (pw = '8a8bA3anjqV.g'));
which returns
exists
--------
t
(1 row)
successfully with either t or f.
I can't seem to figure out why this isn't working with my php script. (It fails for all results (t or f))
Any thoughts would be hugely appreciated.