I am working on a login script and using mysqli OOP style. I write the echo script to check that it fetched the data or not. The result is the login data. But when I want to check the num_rows, it's return zero even if I use $stmt->store_result. I searched for many threads on this website and it doesn't work. mysqli_num_rows doesn't work too. Or I just missed some order of data storing?
Here is my code.
<?php
require_once "condb.php";
if (!isset($_POST['LOGIN']))
  {header("Location:index.php");}
else
{
  $username=mysqli_real_escape_string($cn,$_POST['username']);
  $password=mysqli_real_escape_string($cn,$_POST['password']);
  $hashed_password=password_hash($password,PASSWORD_DEFAULT);
  $login = $cn->prepare("SELECT name,username,password,status
                       FROM login WHERE username=?");
  $login->bind_param("s", $username);
  $login->execute();
  $login->bind_result($name,$username,$password,$status);
  $login->store_result();
  $login->fetch();
  $count=$login->num_rows();
  echo $name."<br />".
  $username."<br />".
  $password."<br />".
  $status."<br />".$count;
/*Below here is if condition that I'll used when I finished solving this 
problem.*/
/*
if ($count > 0 )
{
   if(password_verify($password, $row['password']) && 
   $row['status']=="Admin")
   {
   echo "ok<br>You are Admin!";
   header("Location:admin/admin.php");
   $login->close();
   }elseif(password_verify($password, $row['password']) && 
    $row['status']=="Editor")
    {
      echo "ok<br>You are Editor!";
      $login->close();
    }elseif(password_verify($password, $row['password']) && 
    $row['status']=="Author")
    {
      echo "ok<br>You are Author!";
      $login->close();
     }
 else
 {
   echo "Username or password incorrect";
   $login->close();
   }
}
*/
}
?>
 
    