if(isset($_POST['signin'])){
$password = $_POST['password'];
$email = $_POST['email'];
$query = "SELECT * from `accounts`;";
if(count(fetchAll($query)) > 0){ //this is to catch unknown error.
foreach(fetchAll($query) as $row){
if($row['email']==$email&&$row['password']==$password){
$_SESSION['login'] = true;
$_SESSION['type'] = $row['type'];
header('location:admin.php');
}else{
echo "<script>alert('Wrong login details.')</script>";
header("Location:login.php");
}
}
}else{
echo "<script>alert('Error.')</script>";
}
}
When I enter wrong email address I get an alert 4 times, and I also have 4 users. Does that mean each row is getting counted and I am getting alert after each user is checked. Please help me fix this.