I am having a problem with a comparison operator in an if statement. I get a value from a database, an md5 value and compare it to an md5'd input password. Pretty standard stuff. No matter what password I enter though, the if statement, with the comparison, always evaluates to true. Here's the code:
include('include/constants.php');
include('classes/services/QueryServices.php');
class LoginDBServices extends QueryServices
{
/*
* All queries for logins are handled here
*/
function authenticate($username, $password)
{
//user login query
$query = "SELECT id, CONCAT(first_name, ' ',last_name), security_level, password
FROM users
WHERE email = '$username'";
$this->_assocQuery($query);
$inputPass = md5($password);
$resultSetPass = $this->result[1]['password'];
//check the password against the md5 hash
if($resultSetPass === $inputPass)
{
return $this->result;
}
elseif($resultSetPass !== $inputPass)
{
$_SESSION['valError'] = 'Wrong username or password';
header('location:'.LOGIN_FORM_VIEW);
}
}
}
It always returns my result even though the two variables $resultSetPass and $inputPass are totally different. When I print them out, they are different. Anyone know what could be going on here? Something to do with the fact that its in a class?