Forum Moderators: coopster
Why is that?
<?php
$connection = new mysqli('127.0.0.1', 'root', '', 'main');
$query = 'SELECT username, password FROM user WHERE username = ? AND password = ?';$stmt = $connection->stmt_init();
if($stmt->prepare($query))
{
$stmt->bind_param('ss', $_POST['username'], $_POST['password']);
$stmt->execute();
}
if($stmt)
{
echo 'Your account was found!';
}
else
{
echo 'Your account was NOT found!...hacker';
}
?>
So I added:
$stmt->store_result();
And then changed the if statement to:
if($stmt->num_rows == 1)
And it works!
Is this the proper was to do this?