我现在正在开发一个 php 网站。我正在制作登录页面,当我检查登录代码是否有效时,它打印了整个准备行。
输出:
prepare("select * from login_details where user = ? && pass= ?;");
$stmt>bindValue(1, $name); $stmt->bindValue(2, $pass); $stmt->execute;
$row = $stmt->fetchall(PDO::FETCH_ASSOC); while ($row) { echo "
Failed
"; } ?
我的代码是,
<body>
<?php
include 'connect.php';
if(isset($_POST['username']) && isset($_POST['pass'])){
$name=htmlentities($_POST['username']);
$pass=htmlentities($_POST['pass']);
}
$stmt= $dbh->prepare("select * from login_details where user = ? && pass= ?;");
$stmt->bindValue(1, $name);
$stmt->bindValue(2, $pass);
$stmt->execute;
$row = $stmt->fetchall(PDO::FETCH_ASSOC);
while ($row) {
echo "<h2>Failed</h2>";
}
?></body>
最佳答案
("select * from login_details where user = ? and pass=? ");
它是 and 而不是 &&。您不应在语句中添加终止分号。
关于php - 当我按下登录按钮时,login.php 打印整个准备行 :(,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37314195/