56 lines
1.9 KiB
PHP
56 lines
1.9 KiB
PHP
<?php
|
|
include 'header.php';
|
|
|
|
session_start();
|
|
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
|
|
$config = include 'config.php';
|
|
$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>
|
|
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<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">
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-4">
|
|
<h2 class="text-center mb-4">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 placeholder="Enter username">
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="password" class="form-label">Password</label>
|
|
<input type="password" class="form-control" id="password" name="password" required placeholder="Enter password">
|
|
</div>
|
|
<button type="submit" class="btn btn-primary w-100">Login</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|