I have a simple Login system which won't work and I can't figure out why. Once I press the login button nothing happens, the site just reloads instead of redirecting me or giving me any error messages.
if(!empty($_POST['email']) && !empty($_POST['password'])){
$records = $conn->prepare('SELECT email, password FROM Profiles WHERE email = :email');
$records ->bindParam(':email', $_POST['email']);
$records->execute();
$results = $records->fetch(PDO::FETCH_ASSOC);
$message = '';
if(count($results) > 0 && password_verify($_POST['password'], $results['password'])){
$_SESSION['user_email'] = $results['email'];
header("Location: main.php");
}else{
$message = 'Sorry, those credentials do not match';
}
}
And here's the HTML form.
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="POST">
<input type="text" placeholder="Email" name="email"> <br/> <br/>
<input type="password" placeholder="Password" name="password"> <br/> <br/>
<input type="submit" value="Login">
</form>