validateUser($username, $password); return !(count($result) == 0); } if (isset($_POST['loginButton'])) { $errors = 0; $fields = array("username", "password"); foreach ($fields as $key => $field) { if (!isset($_POST[$field]) || empty($_POST[$field])) { $errors++; break; } } if ($errors <= 0) { $username = $_POST['username']; $password = $_POST['password']; if (checkValidUser($username, $password)) { $_SESSION['username'] = $username; header('Location: admin.php'); } else { $_SESSION['login-error'] = "Invalid username and/or password! Try again!"; } } else { $_SESSION['login-error'] = "Invalid username and/or password! Try again!"; } } if (isset($_POST['indexPage'])) { header('Location: ../../main.html'); } ?> Login

Login

'; echo 'window.alert("Invalid username and/or password")'; echo ''; } ?>