$missingFields = false; if (isset($_GET['submit'])) { if (isset($_GET['username']) && isset($_GET['password'])) { if ($_GET['username'] == "" || $_GET['password'] == "") { $missingFields = true; } else { //All fields set, fields have a value $websiteUser = new WebsiteUser(); if (!$websiteUser->hasDbError()) { $username = $_GET['username']; $password = $_GET['password']; $websiteUser->authenticate($username, $password); if ($websiteUser->isAuthenticated($username, $password)) { $_SESSION['websiteUser'] = $websiteUser; $lastLogin = date("y-m-d"); $websiteUser->lastLogin($username, $password, $lastLogin); $_SESSION["username"] = $username; $_SESSION["password"] = $password; header('Location: mailing_list.php'); } } } } } //Missing username/password if ($missingFields) { echo '<h3 style="color:red;">Please enter both a username and a password</h3>'; } //Authentication failed if (isset($websiteUser)) { if (!$websiteUser->isAuthenticated()) {