$ statement-> num_rows返回0

时间:2015-01-01 11:36:29

标签: php return

我尝试使用电子邮件确认进行登录系统,因此当用户确认电子邮件时,数据库中哈希的值从MD5值变为“已确认”,然后在我使用的logon.php中:

if (isset($_POST['submit']))
{
    $confirmed = 'confirmed';
    $username = $_POST['username'];
    $password = $_POST['password'];

    $query = "SELECT id, username FROM users WHERE username = ? AND hash = ? AND password = SHA(?) LIMIT 1";
    $statement = $databaseConnection->prepare($query);
    $statement->bind_param('sss', $username, $password, $confirmed);

    $statement->execute();
    $statement->store_result();

    if ($statement->num_rows == 1)
    {
        $statement->bind_result($_SESSION['userid'], $_SESSION['username']);
        $statement->fetch();
        header ("Location: index.php");
    }
    else
    {
        echo "Username/password combination is incorrect.";
    }
}

我已经尝试了一切,但$statement->num_rows总是返回0,任何人都可以帮助我吗?请

1 个答案:

答案 0 :(得分:-1)

我认为你在寻找

  $statement->rowCount()

我希望帮助