为什么我的row_count条件总是返回0?

时间:2016-07-01 14:34:21

标签: php

我有这部分代码我的$row_count总是返回值0,即使我有正确的用户名和密码。

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

$stmt = $conn->prepare("SELECT * FROM users WHERE uName = ? AND uPassword = ?");
$stmt->bind_param('ss',$username,$password);
$stmt->execute() or die ($stmt->error);
$get_result=$stmt->get_result();
print_r($get_result); //DEBUG purpose
$row_count= $stmt->num_rows;
print_r($row_count); die;// DEBUG purpose
$stmt->close();
$conn->close();

if ($row_count>0){
    $_SESSION['uName'] = $username;


    echo "Logged in";
    exit();
}else{
    echo "Wrong credentials";
    exit();
}

}

顺便说一下,我的桌子上有更多的行会影响整个过程吗?我的代码总是转到else语句。 mysqli_result Object ( [current_field] => 0 [field_count] => 10 [lengths] => [num_rows] => 0 [type] => 0 )这就是我确定它总是返回0的方式。感谢您的帮助,无需哈希密码只需要返回值>1谢谢。 :d

<html>
<head>
    <title>Login</title>
</head>

<body>
    <form action = "" method = "post">
    <input type = "text" name="username"><br>
    <input type = "password" name = "password"><br>
    <input type = "submit" name = "submit" value = "Login">
    <a href = "register.php">Create Account</a>
    </form>
</body>
</html>

这是表格。

0 个答案:

没有答案