What is wrong with my login function?
This is defined in the class 'Auth':
public function login($username,$password)
{
$loggedin = false;
$password = $this->hashData($password);
$query = "SELECT `Username`, `PWhash` FROM 'user' WHERE 'Username' = '$username'LIMIT 1";
if ($result = mysqli_query($db, $query)){
while ($obj = mysqli_fetch_object($result)){
$dbuser = $obj->Username;
$dbpwd = $obj->PWhash;
if ($dbpwd == $password){
$loggedin = true;
}
else{
$loggedin = false;
exit;
}
mysqli_free_result($result);
}
}
This is the function hashData() that I used (also defined in the same class):
protected function hashData($data){
return hash_hmac('sha512', $data);
}
This is how I tried to use the function (class included in this site with require_once('auth.php'))
$var = new Auth; // instantiating ... seems to work fine
$var->login($username, $password); // this does not work