我不知道为什么它不会返回结果,虽然我正确登录,但是在运行程序时它仍然是假的
<?php
$u = "";
$p = "";
if(isset($_POST['ok'])){
if($_POST['txtuser']==NULL){
echo "Please Enter Your Username<br/>";
}else{
$u = $_POST['txtuser'];
}
if($_POST['txtpass']==NULL){
echo "Please Enter Your Password<br/>";
}else{
$p = $_POST['txtpass'];
}
if($u && $p){
$conn = mysqli_connect("localhost","root", "", "phponline") or die ('connect fail');
$sql = "select * from user where username='$u' and password='$p'";
$query = mysqli_query($conn,$sql);
if(mysqli_num_rows($query) == 0 ){
echo "Wrong username or password, please try again";
}else{
echo "Login Success";
}
}
}
?>