35845-vm/admin/login.php
Flatlogic Bot e0d7dd4af9 first
2025-11-19 14:03:01 +00:00

59 lines
2.1 KiB
PHP

<?php
session_start();
// If already logged in, redirect to admin dashboard
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
header('Location: index.php');
exit;
}
$login_error = '';
$password = 'password123'; // Hardcoded password - NOT FOR PRODUCTION
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['password']) && $_POST['password'] == $password) {
$_SESSION['loggedin'] = true;
header('Location: index.php');
exit;
} else {
$login_error = 'Invalid 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">
<link rel="stylesheet" href="../assets/css/custom.css">
</head>
<body class="dark-theme">
<div class="container">
<div class="row justify-content-center align-items-center" style="height: 100vh;">
<div class="col-md-4">
<div class="card portfolio-item">
<div class="card-body">
<h3 class="card-title text-center">Admin Login</h3>
<form action="login.php" method="POST">
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<?php if ($login_error): ?>
<div class="alert alert-danger"><?php echo $login_error; ?></div>
<?php endif; ?>
<div class="d-grid">
<button type="submit" class="btn btn-accent">Login</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>