48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
|
<?php
|
||
|
session_start();
|
||
|
|
||
|
$config = include 'config.php';
|
||
|
|
||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||
|
$username = $_POST['username'];
|
||
|
$password = $_POST['password'];
|
||
|
|
||
|
if ($username === $config['admin_username'] && password_verify($password, $config['admin_password'])) {
|
||
|
$_SESSION['loggedin'] = true;
|
||
|
header('Location: index.php');
|
||
|
exit();
|
||
|
} else {
|
||
|
$error = 'Invalid username or password';
|
||
|
}
|
||
|
}
|
||
|
?>
|
||
|
|
||
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>Login</title>
|
||
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
|
||
|
</head>
|
||
|
<body>
|
||
|
<div class="container mt-5">
|
||
|
<h2 class="mb-4 text-center">Login</h2>
|
||
|
<?php if (isset($error)): ?>
|
||
|
<div class="alert alert-danger"><?php echo $error; ?></div>
|
||
|
<?php endif; ?>
|
||
|
<form method="post" action="login.php">
|
||
|
<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>
|
||
|
<button type="submit" class="btn btn-primary w-100">Login</button>
|
||
|
</form>
|
||
|
</div>
|
||
|
|
||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
|
||
|
</body>
|
||
|
</html>
|