我的代码没有运行。总是打印 $ errmassage =“用户名或密码不正确”; 。可能是我的查询不完美。但我尝试了很多时间来计算 num_rows 。但是没有工作。请任何人帮助我。
$search= "SELECT * from registermember WHERE email='$username' AND password='$password'";
$result=mysqli_query($conn,$search);
$checkrow=mysqli_num_rows($result);
if ($checkrow > 0) {
$cookie=setcookie("$username",md5('$password'), date()+7200,"/");
$_SESSION['user']=$username;
header("location:mainpage.php");
}
else{
$errmassage="username or password incorrect";
}
答案 0 :(得分:0)
首先做
echo $search;
die;
在phpMyAdmin上测试查询。确保问题是代码或SQL。