新手来了 我在使用 mysqli 的 php 代码中遇到问题。我已将限制设置为 1,但是当我尝试进行一些测试时,例如在 mysqli_stmt_num_rows($stmt); 看看它是否真的取得了一些东西……但结果却是 0。我真的不知道该怎么办了。希望可以有人帮帮我。
这是我的登录代码:
<?php
$con = mysqli_connect("localhost", "root", "", "pamsignup")
or die('error in connection'.mysqli_connect_error());
if(isset($_POST['login'])){
$stmt = mysqli_prepare($con, "SELECT username, password FROM registries
WHERE username=? AND password=? LIMIT 1");
$username= $_POST['username'];
$password = $_POST['password'];
mysqli_stmt_bind_param($stmt, 'ss', $username, $password);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $username, $password);
mysqli_stmt_fetch($stmt);
mysqli_stmt_store_result($stmt);
echo mysqli_stmt_num_rows($stmt);
if(mysqli_stmt_num_rows($stmt) == 1)
{
header('Location: PAM-home.php');
}
else
{
//header('Location: PAM-login.php');
echo 'Wrong Password';
}
mysqli_stmt_close($stmt);
}
?>