【发布时间】:2017-01-07 00:15:46
【问题描述】:
您好,我正在尝试使用在 ec2 实例上运行的 android 和 php 制作登录应用程序,但即使我输入了正确的凭据,我也无法登录。
所以我开始打印查询,如果我打印 $user 我得到的只是“1”有什么建议吗?
public function getUserByEmailAndPassword($email, $password) {
$stmt = $this->conn->prepare("SELECT * FROM users WHERE email=?");
$stmt->bind_param('s', $email);
if ($stmt->execute()) {
$stmt->bind_result($id,$unique_id,$name,$email,$encrypted_password,$salt,$created_at,$updated_at);
$user = $stmt->fetch();
$stmt->close();
// verifying user password
$salt = $user['salt'];
$encrypted_password = $user['encrypted_password'];
$hash = $this->checkhashSSHA($salt, $password);
// check for password equality
if ($encrypted_password == $hash) {
// user authentication details are correct
return $user;
}
} else {
return null;
}
}
【问题讨论】:
-
你正在打印
fetch()的返回,如果成功则为true/1。