Почему не могу авторизоваться? Код вроде бы правильный но не авторизовывает!
Получаю ошибку
Woops! Email and Password cannot be empty...
<?php
session_start();
include "config.php";
if (isset($_POST["login"])) {
if($_POST["username"]=="" or $_POST["email"]=="" or $_POST["password"]=="") {
echo "<script>alert('Woops! Email and Password cannot be empty...')</script>";
} else{
$email = trim($_POST["email"]);
$username = strip_tags(trim($_POST["username"]));
$password = strip_tags(trim($_POST["password"]));
$query=$db->prepare("SELECT * FROM users WHERE email=? AND password=?");
$query->execute(array($email, $password));
$control=$query->fetch(PDO::FETCH_OBJ);
if($control>0) {
$_SESSION["username"]=$username;
header("Location:dashboard.php");
}
echo "<script>alert('Woops! Email or Password is Wrong.')</script>";
}
}
?>
HTML код страницы
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Login Form - Pure Coding</title>
</head>
<body>
<div class="container">
<form action="" method="POST" class="login-email">
<p class="login-text" style="font-size: 2rem; font-weight: 800;">Login</p>
<div class="input-group">
<input type="text" placeholder="Username" name="password">
</div>
<div class="input-group">
<input type="email" placeholder="Email" name="email">
</div>
<div class="input-group">
<input type="password" placeholder="Password" name="password">
</div>
<div class="input-group">
<button type="submit" name="login" class="btn">Login</button>
</div>
</form>
</div>
</body>
</html>