My code is not running.it always print $errmassage="username or password incorrect";. may be my query is not perfect.but i tried many time to count num_rows.but not working.please anybody help me.
$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";
}