39199-vm/admin_login.php
Flatlogic Bot 517061dddb r
2026-03-15 03:04:09 +00:00

67 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
require_once __DIR__ . '/includes/auth.php';
require_once __DIR__ . '/includes/flash.php';
if (is_admin_logged_in()) {
header('Location: admin_dashboard.php');
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = trim($_POST['username'] ?? '');
$password = trim($_POST['password'] ?? '');
if (login_admin($username, $password)) {
header('Location: admin_dashboard.php');
exit;
}
flash_set('danger', 'Username atau password salah.');
header('Location: admin_login.php');
exit;
}
$flash = flash_get();
?>
<!doctype html>
<html lang="id">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Login Admin</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">
<div class="container py-5">
<div class="row justify-content-center">
<div class="col-lg-5">
<div class="card shadow-sm border-0">
<div class="card-body">
<h1 class="h4 fw-semibold mb-3">Login Admin</h1>
<?php if ($flash): ?>
<div class="alert alert-<?= htmlspecialchars($flash['type']) ?> border-0 small">
<?= htmlspecialchars($flash['message']) ?>
</div>
<?php endif; ?>
<form method="post">
<div class="mb-3">
<label class="form-label" for="username">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label class="form-label" for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-dark w-100">Masuk</button>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>