0
In the following code, the following error occurs, which I cannot understand why:
Call to a Member Function fetch_object() on a non-object at 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");
$stmt->get_result()->fetch_object(), I used your suggestion and the same error appears.
– Diana Madeira