In the following code, the following error occurs, which I can not understand why:
Call fetch_object () on a non-object on line 21
<?php
require('config.php');
if (isset($_POST['email']))
{
$email = stripslashes($_REQUEST['email']);
$email = mysqli_real_escape_string($conn,$email);
$password = stripslashes($_REQUEST['password']);
$password = mysqli_real_escape_string($conn,$password);
$stmt = $conn->prepare("SELECT password FROM registo WHERE email=?");
$stmt->bind_param("s",$email);
$email = $_POST['email'];
$stmt->execute();
$result= $stmt->store_result();
if($stmt->affected_rows > 0)
{
$user = $result->fetch_object();//linha 21
if(password_verify($password,$user->password))
{
$_SESSION['email'] = $email;
$_SESSION['user'] = true;
header("Location: home.php");