require_once __DIR__ . '/auth.php'; if (is_logged_in()) redirect('index.php'); $pageTitle = 'Login'; $error = ''; $username = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { verify_csrf(); $username = clean($_POST['username'] ?? '', 100); $password = $_POST['password'] ?? ''; $result = login_user($username, $password); if ($result['ok']) redirect('index.php'); else $error = $result['msg']; } ?>