0

Hello I am trying to make a login app using android and php running on an ec2 instance, but I cant login even if I put the right credentials.
So I started printing the query and if I print $user all I get is "1" any suggestions?

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;
    }
}
1
  • you are printing the return of fetch(), which is true/1 if successfull. Commented Jan 7, 2017 at 0:35

1 Answer 1

1

When you use bind_result, you get the data in the variables that you bind with bind_result.

$stmt->bind_result($id,$unique_id,$name,$email,$encrypted_password,$salt,$created_at,$updated_at);
$stmt->fetch();
echo $unique_id;
$stmt->close();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.