109 lines
4.6 KiB
PHP
109 lines
4.6 KiB
PHP
<?php
|
|
session_start();
|
|
|
|
// Jika sudah login sebagai admin, tendang kembali ke index
|
|
if (isset($_SESSION['role']) && $_SESSION['role'] === 'admin') {
|
|
header("Location: index.php");
|
|
exit;
|
|
}
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$username = $_POST['username'];
|
|
$password = $_POST['password'];
|
|
|
|
include 'koneksi.php';
|
|
|
|
// Query user from database
|
|
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ? LIMIT 1");
|
|
$stmt->bind_param("s", $username);
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
|
|
if ($result && $result->num_rows > 0) {
|
|
$user = $result->fetch_assoc();
|
|
// Check hashed password
|
|
if (password_verify($password, $user['password'])) {
|
|
$_SESSION['role'] = $user['role'];
|
|
$_SESSION['username'] = $user['username'];
|
|
$_SESSION['avatar'] = $user['avatar'];
|
|
header("Location: index.php");
|
|
exit;
|
|
}
|
|
}
|
|
|
|
$error = "Username atau password salah!";
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="id">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Login Admin - WebGIS Pontianak</title>
|
|
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="style.css">
|
|
</head>
|
|
|
|
<body class="login-body">
|
|
|
|
<div class="login-card">
|
|
<div class="login-logo">
|
|
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
<path stroke-linecap="round" stroke-linejoin="round" d="M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-.553-.894L15 4m0 13V4m0 0L9 7" />
|
|
</svg>
|
|
</div>
|
|
<h2>Login Admin</h2>
|
|
<p>Masuk untuk mengelola data WebGIS</p>
|
|
|
|
<?php if (isset($error)): ?>
|
|
<div class="error-msg"><?php echo $error; ?></div>
|
|
<?php endif; ?>
|
|
|
|
<form method="POST" class="login-form">
|
|
<div class="sfield">
|
|
<label class="sfield-label">Username</label>
|
|
<input type="text" name="username" class="sinput" placeholder="Masukkan username..." required autofocus>
|
|
</div>
|
|
<div class="sfield">
|
|
<label class="sfield-label">Password</label>
|
|
<input type="password" name="password" class="sinput" placeholder="Masukkan password..." required>
|
|
</div>
|
|
<button type="submit" class="btn btn-save" style="width: 100%; margin-top: 8px;">Login ke Sistem</button>
|
|
</form>
|
|
|
|
<a href="index.php" class="back-link">← Kembali ke Peta</a>
|
|
|
|
<div style="margin-top: 30px; padding: 16px; background-color: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 10px; text-align: left;">
|
|
|
|
<p style="margin: 0 0 12px 0; font-size: 12px; color: #94a3b8; font-weight: 600; text-align: center; letter-spacing: 1px;">
|
|
Akun Admin
|
|
</p>
|
|
|
|
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px;">
|
|
<span style="color: #cbd5e1;"><span style="opacity: 0.7;">Admin</span></span>
|
|
<span style="color: #3b82f6; background-color: rgba(59, 130, 246, 0.1); padding: 3px 8px; border-radius: 4px; font-weight: 600;">admin</span>
|
|
</div>
|
|
|
|
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px;">
|
|
<span style="color: #cbd5e1;"><span style="opacity: 0.7;">Admin Tingkat Provinsi</span></span>
|
|
<span style="color: #3b82f6; background-color: rgba(59, 130, 246, 0.1); padding: 3px 8px; border-radius: 4px; font-weight: 600;">adminProvinsi</span>
|
|
</div>
|
|
|
|
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 13px;">
|
|
<span style="color: #cbd5e1;"> <span style="opacity: 0.7;">Admin Tingkat Kota</span></span>
|
|
<span style="color: #3b82f6; background-color: rgba(59, 130, 246, 0.1); padding: 3px 8px; border-radius: 4px; font-weight: 600;">adminKota</span>
|
|
</div>
|
|
|
|
<div style="border-top: 1px dashed rgba(255, 255, 255, 0.1); padding-top: 10px; text-align: center; font-size: 12px; color: #64748b;">
|
|
Password semua akun: <code style="color: #f87171; font-family: monospace; font-size: 13px;">password</code>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|