35432-vm/login.php
Flatlogic Bot d51486c0fb 2.1a
2025-11-03 03:42:58 +00:00

88 lines
3.0 KiB
PHP

<?php
session_start();
// Hardcoded credentials for simplicity
define('ADMIN_USERNAME', 'admin');
define('ADMIN_PASSWORD', 'password');
$error_message = '';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$username = $_POST['username'] ?? '';
$password = $_POST['password'] ?? '';
if ($username === ADMIN_USERNAME && $password === ADMIN_PASSWORD) {
$_SESSION['loggedin'] = true;
$_SESSION['username'] = $username;
header('Location: admin.php');
exit;
} else {
$error_message = 'Username atau password salah.';
}
}
// If user is already logged in, redirect to admin page
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
header('Location: admin.php');
exit;
}
?>
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Admin - Juanda Rent & Tour</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
<style>
body {
background-color: #f8f9fa;
}
.login-container {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.login-card {
max-width: 400px;
width: 100%;
padding: 2rem;
border: none;
border-radius: 0.75rem;
box-shadow: 0 0.5rem 1.5rem rgba(0,0,0,0.1);
}
</style>
</head>
<body>
<div class="login-container">
<div class="card login-card">
<div class="card-body">
<h3 class="card-title text-center mb-4">Admin Login</h3>
<?php if ($error_message): ?>
<div class="alert alert-danger"><?php echo htmlspecialchars($error_message); ?></div>
<?php endif; ?>
<form action="login.php" method="POST">
<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>
<div class="d-grid">
<button type="submit" class="btn btn-primary">Login</button>
</div>
</form>
<div class="text-center mt-3">
<a href="index.php">Kembali ke Halaman Utama</a>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>