我的登录功能有什么问题?
这在“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);
}
}
这是我使用的函数hashData()(也在同一个类中定义):
protected function hashData($data){
return hash_hmac('sha512', $data);
}
这就是我尝试使用该函数的方法(此网站包含的类包含require_once('auth.php'))
$var = new Auth; // instantiating ... seems to work fine
$var->login($username, $password); // this does not work