Show sourcecode
The following files exists in this folder. Click to view.
admin.php
admin_login.php
api/
config.php
css/
db_setup.php
index.php
js/
results.php
tests/
admin_login.php
65 lines ASCII Unix (LF)
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
<?php
session_start();
// Hardcoded admin credentials
define('ADMIN_USER', 'admin');
define('ADMIN_PASS', 'admin123');
$error = '';
// Handle logout
if (isset($_GET['logout'])) {
unset($_SESSION['admin_logged_in']);
session_destroy();
header('Location: admin_login.php');
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$user = trim($_POST['username'] ?? '');
$pass = $_POST['password'] ?? '';
if ($user === ADMIN_USER && $pass === ADMIN_PASS) {
$_SESSION['admin_logged_in'] = true;
header('Location: admin.php');
exit;
} else {
$error = 'Invalid username or password.';
}
}
// Already logged in? Redirect to dashboard
if (!empty($_SESSION['admin_logged_in'])) {
header('Location: admin.php');
exit;
}
?>
<!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 rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
<h1>Admin Login</h1>
<?php if ($error): ?>
<p style="color: #dc2626; font-weight: 600;"><?= htmlspecialchars($error) ?></p>
<?php endif; ?>
<form method="POST" action="">
<div class="form-group">
<label for="username">Username</label>
<input type="text" id="username" name="username" required autofocus>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary">Log In</button>
</form>
</div>
</body>
</html>