Hello, how can I improve this form login with error alerts?
For example, if the fields are empty, if entered data do not match any user, etc. etc.
Right now my form is so, taking advantage of a class:
if(isset($_POST['login'])){
//Retrieve the field values from our login form.
$username = !empty($_POST['username']) ? trim($_POST['username']) : null;
$password = !empty($_POST['password']) ? trim($_POST['password']) : null;
if($user->login($username, $password)) {
header('Location: index.php');
} else {
$message[] = 'We found problems with the login, please try again.';
}
}