[英]php mysqli bind_result returns 1
您好,我正在尝试使用在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;
}
}
使用bind_result时,您将获得与bind_result绑定的变量中的数据。
$stmt->bind_result($id,$unique_id,$name,$email,$encrypted_password,$salt,$created_at,$updated_at);
$stmt->fetch();
echo $unique_id;
$stmt->close();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.