120 lines
5.1 KiB
PHP
120 lines
5.1 KiB
PHP
<?php
|
|
session_start();
|
|
require 'config.php';
|
|
|
|
if (isset($_SESSION['admin'])) {
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
|
|
$error = '';
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$username = $_POST['username'] ?? '';
|
|
$password = $_POST['password'] ?? '';
|
|
|
|
$stmt = $conn->prepare("SELECT id, password FROM admins WHERE username = ?");
|
|
$stmt->bind_param("s", $username);
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
|
|
if ($row = $result->fetch_assoc()) {
|
|
if (password_verify($password, $row['password'])) {
|
|
$_SESSION['admin'] = $row['id'];
|
|
header('Location: index.php');
|
|
exit;
|
|
} else {
|
|
$error = 'Password salah!';
|
|
}
|
|
} else {
|
|
$error = 'Username tidak ditemukan!';
|
|
}
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="id">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Login Admin - WebGIS Pontianak</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<style>
|
|
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');
|
|
* { margin:0; padding:0; box-sizing:border-box; }
|
|
body {
|
|
font-family: 'Inter', sans-serif;
|
|
background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 40%, #312e81 100%);
|
|
display: flex; align-items: center; justify-content: center;
|
|
height: 100vh;
|
|
}
|
|
.login-container {
|
|
background: rgba(255,255,255,0.97); border-radius: 28px;
|
|
padding: 48px 40px; width: 440px; max-width: 92vw;
|
|
box-shadow: 0 32px 100px rgba(0,0,0,0.35);
|
|
animation: slideUp 0.7s ease;
|
|
}
|
|
@keyframes slideUp {
|
|
from { opacity:0; transform: translateY(50px) scale(0.97); }
|
|
to { opacity:1; transform: translateY(0) scale(1); }
|
|
}
|
|
.login-logo { text-align:center; margin-bottom:36px; }
|
|
.logo-ring {
|
|
width:80px; height:80px; border-radius:24px; margin:0 auto 16px;
|
|
background: linear-gradient(135deg,#6366f1,#8b5cf6);
|
|
display:flex; align-items:center; justify-content:center;
|
|
box-shadow: 0 8px 32px rgba(99,102,241,0.4);
|
|
}
|
|
.logo-ring svg { width:40px; height:40px; fill:white; }
|
|
.login-logo h1 { font-size:24px; font-weight:800; color:#1e293b; }
|
|
.login-logo p { font-size:13px; color:#64748b; margin-top:6px; }
|
|
.form-group { margin-bottom:18px; }
|
|
.form-group label {
|
|
display:block; font-size:12px; font-weight:600;
|
|
color:#64748b; margin-bottom:6px; text-transform:uppercase;
|
|
}
|
|
.form-group input {
|
|
width:100%; padding:12px 16px; border:2px solid #e2e8f0;
|
|
border-radius:8px; font-size:14px; font-family:inherit;
|
|
background:#f1f5f9; outline:none; transition:all 0.2s;
|
|
}
|
|
.form-group input:focus {
|
|
border-color:#6366f1; background:white;
|
|
box-shadow:0 0 0 4px rgba(99,102,241,0.1);
|
|
}
|
|
.login-btn {
|
|
width:100%; padding:14px; background:linear-gradient(135deg,#6366f1,#8b5cf6);
|
|
color:white; border:none; border-radius:8px; font-size:15px;
|
|
font-weight:700; cursor:pointer; font-family:inherit;
|
|
box-shadow:0 4px 16px rgba(99,102,241,0.3); transition:all 0.3s;
|
|
}
|
|
.login-btn:hover { transform:translateY(-2px); box-shadow:0 8px 24px rgba(99,102,241,0.4); }
|
|
.error { color:#ef4444; text-align:center; margin-bottom:10px; font-size:13px; }
|
|
.back-link { display:block; text-align:center; margin-top:20px; color:#64748b; text-decoration:none; font-size:13px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="login-container">
|
|
<div class="login-logo">
|
|
<div class="logo-ring">
|
|
<svg viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"/></svg>
|
|
</div>
|
|
<h1>WebGIS Kemiskinan</h1>
|
|
<p>Kota Pontianak, Kalimantan Barat</p>
|
|
</div>
|
|
<?php if ($error): ?>
|
|
<p class="error"><?= htmlspecialchars($error) ?></p>
|
|
<?php endif; ?>
|
|
<form method="POST">
|
|
<div class="form-group">
|
|
<label>Username</label>
|
|
<input type="text" name="username" placeholder="Masukkan username" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Password</label>
|
|
<input type="password" name="password" placeholder="Masukkan password" required>
|
|
</div>
|
|
<button type="submit" class="login-btn">🔐 Masuk ke Panel Admin</button>
|
|
</form>
|
|
<a href="index.php" class="back-link">← Kembali ke Peta Publik</a>
|
|
<p style="text-align:center;margin-top:12px;font-size:11px;color:#94a3b8;">Demo: username <b>admin</b>, password <b>admin123</b></p>
|
|
</div>
|
|
</body>
|
|
</html>
|