diff options
| author | ilotterytea <iltsu@alright.party> | 2025-08-18 11:21:23 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-08-18 11:21:23 +0500 |
| commit | d3f06ef7ce62a632c3f3323f1877729b5be8aca6 (patch) | |
| tree | d40543ee2296f774d68644380f7c1070a2743d0c /login.php | |
| parent | 8fed544dcac0ab717ca98cca26753d0e9470e529 (diff) | |
feat: alerts
Diffstat (limited to 'login.php')
| -rw-r--r-- | login.php | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -2,13 +2,14 @@ include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/partials.php'; include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/utils.php'; include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/config.php'; +include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/alert.php'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $username = $_POST['username'] ?? null; $password = $_POST['password'] ?? null; if (!isset($username, $password)) { - exit(json_response(400, 'Username and password must be sent!', null)); + exit(create_alert('/login.php', 400, 'Username and password must be sent!', null)); } $db = new PDO(DB_URL, DB_USER, DB_PASS); @@ -18,16 +19,16 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { $user = $stmt->fetch(PDO::FETCH_ASSOC) ?: null; if (!$user) { - exit(json_response(401, 'Incorrect username or password.', null)); + exit(create_alert('/login.php', 401, 'Incorrect username or password.', null)); } if (!password_verify($password, $user['password'])) { - exit(json_response(401, 'Incorrect username or password.', null)); + exit(create_alert('/login.php', 401, 'Incorrect username or password.', null)); } $_SESSION['user'] = $user; - exit(json_response(200, null, $user)); + exit(create_alert('/', 200, null, $user)); } ?> <!DOCTYPE html> @@ -42,6 +43,8 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { <main> <?php html_navbar(); ?> + <?php display_alert(); ?> + <form action="/login.php" method="post" class="column gap-16"> <h1>Log in to your ilt.su account</h1> |
