使用PHP PDO在while($ row-> $ statement-> fetch())中不起作用

时间:2018-11-22 18:08:40

标签: php pdo while-loop fetch

if(isset($_POST['btnLogin']))
{
$username = $_POST['txtusername'];
$pass_word = $_POST['txtpassword'];
$hashed_password = crypt(sha1($pass_word));


$sqlQuery  = "SELECT * from users WHERE username = :username AND password = :password" ;
$statement = $conn->prepare($sqlQuery);
$statement->execute(array(':username' =>$user , ':password'=>$hashed_password));

while($row->$statement->fetch())
{
    $id       = $row['id'];
    $username = $row['username'];
    $password = $row['password'];

    if(strcmp('$password', '$hashed_password') == 0)
    {
        echo "<script type='text/javascript'>console.log("Sucess");</script>";
    }
    else
    {
        echo "<script type='text/javascript'>console.log("Failed");</script>";
    }

}

}

在这里,我正在使用PHP PDO代码实现登录页面。 我以前没有使用PHP PDO的经验。我在“注册”页面上没有出现任何错误,但是很遗憾,程序在之后没有执行

  

while($ row-> $ statement-> fetch())

这是HTML代码

<section>

    <div class="container">
        <div class="login-form">
            <h1>Sign In</h1>
            <form id="login-form" method="post" action="">
            <div class="form-group">
                <input type="text" name="txtusername" placeholder="Username" data-validation="required">
            </div>
            <div>
                <input type="password" name="txtpassword" placeholder="Password" data-validation="required">
            </div>
                <input type="submit" name="btnLogin" value="Login">
            </form>
        </div>
    </div>
</section>

PHP版本:5.3.8

请给我任何解决建议

1 个答案:

答案 0 :(得分:0)

尝试以下方法。如果不起作用,请wrap your query in this并打开错误报告。

A_flattened = tf.reshape(A, [-1, 3])# flatten it out
B_flattened = tf.reshape(B, [-1, 3])
AB_flattened = tf.map_fn(convert_to_mat, (A_flattened, B_flattened))# convert_to_mat should return a 4x4 matrix
AB = tf.reshape(AB_flattened, [M, N, 4, 4])

}