1

I have this code from tutorial, but my DB doesn't support get_result(). I've read that you can change that with bind_param(), but I'm not quite sure how it works. And I don't know how to apply it in my situation

public function getUserByEmailAndPassword($email, $password) {

        $stmt = $this->conn->prepare("SELECT * FROM tbl_login WHERE email = ?");

        $stmt->bind_param("s", $email);

        if ($stmt->execute()) {

            $user = $stmt->get_result()->fetch_assoc();

            $stmt->close();

            // verifying user password
            $salt = $user['salt'];
            $encrypted_password = $user['password'];
            $hash = $this->checkhashSSHA($salt, $password);
            // check for password equality
            if ($encrypted_password == $hash) {
                // user authentication details are correct
                return $user;
            }
        } else {
            return NULL;
        }
    }

How do I change the $user = $stmt->get_result()->fetch_assoc(); line to still make it work as it should here?

giedriusx3
  • 123
  • 2
  • 8

0 Answers0