<?php // session_start(); require_once 'initializer.php'; $user_log = new UserLogin(); $message = ''; $error = ['Invalid password', 'Invalid username', "Invalid username and password"]; // $hasError = new ErrorManager(); if (isset($_SESSION['username']) && strlen($_SESSION['username']) > 0) { if ($user_log->isLogged()) { header('Location: account.php'); exit; } } else { if ($_SERVER['REQUEST_METHOD'] == "POST") { if (isset($_POST['username']) && isset($_POST['password'])) { $username = $_POST['username']; $password = $_POST['password']; $usernameValidator = new UsernameValidator(); $passwordValidator = new PasswordValidator(); // if()){ // // if(!(strlen($username) > 5)){ // echo "dog"; // $user_log->startSession(); // // } // } else { // echo "error username is invalid"; // } if ($passwordValidator->isValid($password) && $usernameValidator->isValid($username)) { // if(strlen($_POST['password']) > 7){ $_SESSION['username'] = $_POST['username'];
<?php require_once 'classes/initialize.php'; $userLogin = new UserLogin(); if (!$userLogin->isLogged()) { header('Location: index.php'); } require_once 'header.php'; ?> <p>Hello <?php echo $userLogin->getUsername(); ?> , thanks for logging in!</p> <a href="logout.php">Logout</a> <?php require_once 'footer.php';