My Log in form works even with the wrong username and password. I have tried searching for answers but I can't find my mistake. Here's the code:
<?php
include 'database.php'; ?>
<?php
if($_SERVER["REQUEST_METHOD"] == "POST"){
$username = mysqli_real_escape_string($connect,$_POST['username']);
$password = mysqli_real_escape_string($connect,$_POST['password']);
$query = "SELECT username, password FROM tbl_membership WHERE username =
'$username' AND password = '$password'";
$result = mysqli_query($connect, $query);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
$active = $row['active'];
$count = mysqli_num_rows($result);
if(mysqli_num_rows($query) > 0){
$_SESSION["username"] = $username;
$_SESSION["password"] = $password;
header("location: welcome.php");
exit();
}if (mysqli_num_rows($query) != 0){
echo "Invalid.";
}
}
?>