I have some basic php code which attempts to authenticate against a username and password in a database. It is supposed to print "Authenticated" if there is a successful match of user & pass. However, the query is not returning any data. In addition, the isset() I am using to check if any data is returned shows that the array has values in it.
What is going wrong here, how can I get this pdo query to return the requested data?
Here is the code with issues.
$stmt = $pd->prepare("SELECT username from users where username = :logon and password = :passwd");
$stmt->bindParam(':logon', $_POST['username'], PDO::PARAM_STR);
$stmt->bindParam(':passwd', $_POST['password'], PDO::PARAM_STR);
$stmt->execute();
$verify_auth = $stmt->fetchAll();
if(isset($verify_auth)){
echo "Authenticated locally";
$authed = 1;
//do something here
}
elseif($authed != 1){
echo "<b>Failure to authenticate</b>";
}
Every time it runs "Authenticated locally" even though the credentials are wrong.
The verify_auth array appears to always be empty even with the correct credentials.
The post parameters are being assigned successfully.
PDOStatement::fetchAllReturn values: php.net/manual/en/…