代码将显示返回的值,如果它大于一,它将返回“是”。但是我在使用 $check 中的 WHERE 子句时遇到了问题。当我把它拿出来时,代码工作得很好,但是当我添加它时,页面返回不正确的值。有什么想法有什么问题吗?
<?php
$con = mysqli_connect("127.0.0.1","root","","lian");
$u= $_GET['username'];
$pw = $_GET['password'];
$check = "SELECT username,password FROM users WHERE username='$u' AND password='$pw'";
$login = mysqli_query($con,$check) or die(mysqli_error($con));
$num_rows = mysqli_num_rows($login);
echo "$num_rows \n";
if (mysqli_num_rows($login) == 1) {
$row = mysqli_fetch_assoc($login);
echo 'Yes';
exit;
}
else {
echo 'No';
exit;
}