So it is my first day working in MYSQLi(converting over from mysql), and I am having trouble with my login script where I check for duplicate emails:
Here is what i've got:
$email = mysqli_escape_string($_POST['email']);
$stmt=$mysqli->prepare("SELECT username from users WHERE email=?");
$stmt->bind_param('s',$email);
$stmt->execute();
$nrows1=$mysqli->num_rows;
echo $nrows1;
$stmt->close();
if ($nrows1>0) {
$_SESSION['loggedin'] = false;
$_SESSION['error'] = "Our records indicate that there is already an account registered with that email. Please use the 'forgot your password' link below if you cannot remember your password.";
header('Location: registration.php');
echo "running insisde duplicate email";
exit();
}
I keep returning 0 rows or an empty variable when echoing $nrows1. When I enter the query directly in sql, it works fine. I seem to be following the documents and have tinkered a bunch with it.
I also used the affected rows function, but I do not believe that is appropriate for a SELECT statement, correct?
Sincere thanks for any help, it is greatly appreciated.