Files
radio-free-elsewhere/admin/login.php
T

50 lines
1.3 KiB
PHP
Executable File

<?php
require __DIR__ . '/../includes/auth.php';
require __DIR__ . '/../includes/admin_layout.php';
if (currentAdmin() !== null) {
header('Location: index.php');
exit;
}
$error = null;
$username = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
verifyCsrf();
$username = trim((string)($_POST['username'] ?? ''));
$password = (string)($_POST['password'] ?? '');
$error = attemptLogin($username, $password);
if ($error === null) {
header('Location: index.php');
exit;
}
}
adminHeader('Log In');
?>
<?php if ($error): ?>
<p class="admin-message error"><?= e($error) ?></p>
<?php endif; ?>
<form method="post" action="login.php">
<?= csrfField() ?>
<div class="row gtr-uniform gtr-50">
<div class="col-12">
<label for="username">Username</label>
<input type="text" name="username" id="username" value="<?= e($username) ?>" autocomplete="username" required autofocus />
</div>
<div class="col-12">
<label for="password">Password</label>
<input type="password" name="password" id="password" autocomplete="current-password" required />
</div>
<div class="col-12">
<ul class="actions">
<li><input type="submit" class="primary" value="Log In" /></li>
</ul>
</div>
</div>
</form>
<?php
adminFooter();