36525-vm/admin/login.php
Flatlogic Bot 232ed5c114 V3
2025-12-01 09:10:54 +00:00

68 lines
2.2 KiB
PHP

<?php
session_start();
require_once __DIR__ . '/../lib.php';
require_once __DIR__ . '/../db/config.php';
if (is_logged_in()) {
header('Location: /admin/');
exit;
}
$error = null;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'] ?? '';
$password = $_POST['password'] ?? '';
if (login($username, $password)) {
header('Location: /admin/');
exit;
} else {
$error = 'Invalid username or password';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Login</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card mt-5">
<div class="card-header">
<h3 class="text-center">Admin Login</h3>
</div>
<div class="card-body">
<?php if ($error): ?>
<div class="alert alert-danger"><?= $error ?></div>
<?php endif; ?>
<form action="/admin/login.php" method="post">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary">Login</button>
</div>
</form>
<div class="text-center mt-3">
<p>Don't have an account? <a href="/registration.php">Register here</a></p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>