<?php $auth = new EAuth($mysqli); if ($auth->isLogged($mysqli)) { header('Location: http://localhost'); } if (isset($_POST['username']) && isset($_POST['password'])) { $username = $_POST['username']; $password = $_POST['password']; $remember = $_POST['remember']; $login = $auth->login($username, $password, $remember); if (!$login['error']) { setcookie(COOKIE_EAUTH, $login['hash'], $login['expire'], '/'); header('Location: ' . $_SERVER['HTTP_REFERER']); } else { $error = $login['message']; } } ?> <section> <div id="login"> <h2>Logga in</h2> <div><?php echo $error; ?> </div> <form method="POST"> <input type="text" name="username" placeholder="Användarnamn eller e-post"> <input type="password" name="password" placeholder="Lösenord"> <input type="submit" value="Logga in">