fix: update final code deployment
This commit is contained in:
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (isset($_SESSION['user'])) {
|
||||
header('Location: ' . ($_SESSION['role'] === 'superadmin' ? 'dashboard.php' : 'index.php'));
|
||||
exit;
|
||||
}
|
||||
$err = '';
|
||||
$selectedRole = $_POST['role'] ?? 'admin';
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
require 'config.php';
|
||||
$u = $conn->real_escape_string($_POST['username'] ?? '');
|
||||
$role = $_POST['role'] ?? '';
|
||||
if ($role === 'admin') {
|
||||
$row = $conn->query("SELECT * FROM users WHERE username='$u' AND role IN ('admin','user')")->fetch_assoc();
|
||||
} else {
|
||||
$roleEsc = $conn->real_escape_string($role);
|
||||
$row = $conn->query("SELECT * FROM users WHERE username='$u' AND role='$roleEsc'")->fetch_assoc();
|
||||
}
|
||||
if ($row && password_verify($_POST['password'] ?? '', $row['password'])) {
|
||||
session_regenerate_id(true);
|
||||
$_SESSION['user'] = $row['id'];
|
||||
$_SESSION['nama'] = $row['nama'];
|
||||
$_SESSION['role'] = $row['role'];
|
||||
header('Location: ' . ($row['role'] === 'superadmin' ? 'dashboard.php' : 'index.php'));
|
||||
exit;
|
||||
}
|
||||
$err = 'Kredensial tidak valid untuk peran yang dipilih.';
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Masuk — Poverty Map</title>
|
||||
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--text: #0f172a; --text2: #64748b; --border: #e2e8f0;
|
||||
--navy: #08184fff; --blue: #08184fff;
|
||||
}
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
html, body { height: 100%; }
|
||||
body {
|
||||
display: flex; flex-direction: column; font-family: 'DM Sans', sans-serif;
|
||||
background: #fff; color: var(--text); overflow: hidden;
|
||||
}
|
||||
|
||||
.login-header {
|
||||
flex-shrink: 0; height: 56px; display: flex; align-items: center;
|
||||
padding: 0 28px; border-bottom: 1px solid var(--border); background: #fff;
|
||||
}
|
||||
.login-header a {
|
||||
font-size: 13px; font-weight: 600; color: var(--text2); text-decoration: none;
|
||||
display: inline-flex; align-items: center; gap: 6px;
|
||||
}
|
||||
.login-header a:hover { color: var(--text); }
|
||||
.login-header span {
|
||||
margin-left: auto; font-size: 12px; color: var(--text2);
|
||||
}
|
||||
|
||||
.login-body { flex: 1; display: flex; min-height: 0; }
|
||||
|
||||
.panel-left {
|
||||
flex: 1; display: flex; flex-direction: column; justify-content: center;
|
||||
padding: 40px 56px; background: var(--navy); color: #fff; overflow-y: auto;
|
||||
}
|
||||
.pl-label {
|
||||
font-size: 11px; font-weight: 700; letter-spacing: .08em;
|
||||
text-transform: uppercase; color: rgba(255,255,255,.5); margin-bottom: 16px;
|
||||
}
|
||||
.pl-title { font-size: clamp(26px, 3vw, 36px); font-weight: 700; line-height: 1.25; margin-bottom: 14px; max-width: 400px; }
|
||||
.pl-desc { font-size: 15px; line-height: 1.65; color: rgba(255,255,255,.7); max-width: 380px; margin-bottom: 32px; }
|
||||
.pl-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
|
||||
.pl-list li {
|
||||
font-size: 14px; color: rgba(255,255,255,.75); padding-left: 18px; position: relative;
|
||||
}
|
||||
.pl-list li::before {
|
||||
content: ''; position: absolute; left: 0; top: 8px;
|
||||
width: 5px; height: 5px; border-radius: 50%; background: rgba(255,255,255,.35);
|
||||
}
|
||||
|
||||
.panel-right {
|
||||
flex: 1; display: flex; align-items: center; justify-content: center;
|
||||
padding: 40px 48px; background: #f8fafc; overflow-y: auto;
|
||||
}
|
||||
.login-form { width: 100%; max-width: 380px; }
|
||||
.lf-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
|
||||
.lf-sub { font-size: 14px; color: var(--text2); margin-bottom: 28px; }
|
||||
|
||||
.role-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 22px; }
|
||||
.role-card { cursor: pointer; }
|
||||
.role-card input { position: absolute; opacity: 0; pointer-events: none; }
|
||||
.role-card-inner {
|
||||
display: block; padding: 14px; border: 1px solid var(--border);
|
||||
border-radius: 10px; background: #fff; transition: border-color .15s, box-shadow .15s;
|
||||
}
|
||||
.role-card input:checked + .role-card-inner {
|
||||
border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30,58,138,.08);
|
||||
}
|
||||
.role-card strong { display: block; font-size: 13px; font-weight: 700; margin-bottom: 2px; }
|
||||
.role-card small { font-size: 11px; color: var(--text2); line-height: 1.4; }
|
||||
|
||||
.field-label {
|
||||
display: block; font-size: 12px; font-weight: 600;
|
||||
color: var(--text2); margin-bottom: 6px;
|
||||
}
|
||||
.field-input {
|
||||
width: 100%; padding: 11px 13px; border: 1px solid var(--border);
|
||||
border-radius: 8px; font-size: 14px; font-family: inherit;
|
||||
margin-bottom: 14px; background: #fff; transition: border-color .15s, box-shadow .15s;
|
||||
}
|
||||
.field-input:focus {
|
||||
outline: none; border-color: var(--blue);
|
||||
box-shadow: 0 0 0 3px rgba(30,58,138,.08);
|
||||
}
|
||||
.btn-submit {
|
||||
width: 100%; padding: 12px; background: var(--blue); color: #fff;
|
||||
border: none; border-radius: 8px; font-size: 14px; font-weight: 600;
|
||||
cursor: pointer; font-family: inherit; margin-top: 6px;
|
||||
}
|
||||
.btn-submit:hover { background: #1e3a8a; }
|
||||
.err {
|
||||
background: #fef2f2; color: #b91c1c; padding: 11px 13px;
|
||||
border-radius: 8px; font-size: 13px; margin-bottom: 16px; border: 1px solid #fecaca;
|
||||
}
|
||||
.lf-foot { margin-top: 22px; font-size: 12px; color: var(--text2); text-align: center; }
|
||||
|
||||
@media (max-width: 860px) {
|
||||
body { overflow: auto; height: auto; min-height: 100vh; }
|
||||
.login-body { flex-direction: column; }
|
||||
.panel-left { padding: 32px 28px; }
|
||||
.panel-right { padding: 32px 24px 48px; }
|
||||
.pl-list { display: none; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header class="login-header">
|
||||
<a href="../index.php">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><path d="M19 12H5M12 19l-7-7 7-7"/></svg>
|
||||
Portal WebGIS
|
||||
</a>
|
||||
<span>Poverty Map · Pontianak</span>
|
||||
</header>
|
||||
|
||||
<div class="login-body">
|
||||
<div class="panel-left">
|
||||
<div class="pl-label">Sistem Informasi Geografis</div>
|
||||
<h1 class="pl-title">Poverty Map</h1>
|
||||
<p class="pl-desc">Pemetaan rumah ibadah dan penduduk miskin untuk perencanaan program binaan berbasis lokasi.</p>
|
||||
<ul class="pl-list">
|
||||
<li>Peta interaktif rumah ibadah dan kepala keluarga</li>
|
||||
<li>Analisis radius cakupan binaan</li>
|
||||
<li>Manajemen data untuk super admin</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel-right">
|
||||
<div class="login-form">
|
||||
<h2 class="lf-title">Masuk ke sistem</h2>
|
||||
<p class="lf-sub">Pilih peran, lalu masukkan username dan password.</p>
|
||||
|
||||
<?php if ($err): ?><div class="err"><?= htmlspecialchars($err) ?></div><?php endif ?>
|
||||
|
||||
<form method="POST" autocomplete="on">
|
||||
<span class="field-label">Peran akses</span>
|
||||
<div class="role-picker">
|
||||
<label class="role-card">
|
||||
<input type="radio" name="role" value="superadmin" <?= $selectedRole === 'superadmin' ? 'checked' : '' ?> required>
|
||||
<span class="role-card-inner">
|
||||
<strong>Super Admin</strong>
|
||||
<small>Dashboard dan kelola data</small>
|
||||
</span>
|
||||
</label>
|
||||
<label class="role-card">
|
||||
<input type="radio" name="role" value="admin" <?= $selectedRole === 'admin' ? 'checked' : '' ?>>
|
||||
<span class="role-card-inner">
|
||||
<strong>Admin</strong>
|
||||
<small>Peta input dan edit lapangan</small>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<label class="field-label" for="username">Username</label>
|
||||
<input class="field-input" type="text" id="username" name="username" required placeholder="Username" value="<?= htmlspecialchars($_POST['username'] ?? '') ?>">
|
||||
|
||||
<label class="field-label" for="password">Password</label>
|
||||
<input class="field-input" type="password" id="password" name="password" required placeholder="Password">
|
||||
|
||||
<button type="submit" class="btn-submit">Masuk</button>
|
||||
</form>
|
||||
<p class="lf-foot">Dinas Sosial · Kabupaten/Kota Pontianak</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user