Files
karczma-aplikacja-stoliki/public/staff/login.php

56 lines
2.4 KiB
PHP

<?php
require_once __DIR__ . '/auth.php';
startAdminSession();
if (isAdminLoggedIn()) {
header('Location: index.php');
exit;
}
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = trim((string)($_POST['username'] ?? ''));
$password = (string)($_POST['password'] ?? '');
if (attemptAdminLogin($username, $password)) {
header('Location: index.php');
exit;
}
$error = 'Nieprawidłowy login lub hasło.';
}
?>
<!doctype html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Panel Admina - Logowanie</title>
<style>
body { font-family: Inter, Arial, sans-serif; background: #0f172a; color: #e2e8f0; margin: 0; min-height: 100vh; display: grid; place-items: center; }
.card { width: min(420px, 92vw); background: #111827; border: 1px solid #334155; border-radius: 14px; padding: 24px; }
h1 { margin: 0 0 8px; font-size: 1.4rem; }
p { margin: 0 0 20px; color: #94a3b8; }
label { display: block; margin-bottom: 6px; font-size: .9rem; color: #cbd5e1; }
input { width: 100%; box-sizing: border-box; border: 1px solid #475569; background: #0b1220; color: #e2e8f0; border-radius: 10px; padding: 11px 12px; margin-bottom: 14px; }
button { width: 100%; border: 0; border-radius: 10px; padding: 11px 12px; background: #3b82f6; color: #fff; font-weight: 600; cursor: pointer; }
.error { margin-bottom: 12px; padding: 10px; border-radius: 9px; background: #451a1a; color: #fecaca; border: 1px solid #7f1d1d; }
.hint { margin-top: 14px; font-size: .82rem; color: #64748b; }
</style>
</head>
<body>
<form class="card" method="post" action="">
<h1>Panel Admina</h1>
<p>Zaloguj się, aby przejść do KDS, generatora QR i analityki.</p>
<?php if ($error !== ''): ?>
<div class="error"><?= htmlspecialchars($error, ENT_QUOTES, 'UTF-8') ?></div>
<?php endif; ?>
<label for="username">Login</label>
<input id="username" name="username" required autocomplete="username">
<label for="password">Hasło</label>
<input id="password" name="password" type="password" required autocomplete="current-password">
<button type="submit">Zaloguj</button>
<div class="hint">Dane logowania są ustawione w pliku `public/staff/auth.php`.</div>
</form>
</body>
</html>