54 lines
3.2 KiB
PHP
54 lines
3.2 KiB
PHP
<?php
|
|
require_once __DIR__ . '/auth.php';
|
|
|
|
if (is_logged_in()) {
|
|
header('Location: dashboard.php');
|
|
exit;
|
|
}
|
|
|
|
$error = '';
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$username = clean_text(post('username'), 50);
|
|
$password = post('password');
|
|
|
|
$stmt = $koneksi->prepare("SELECT * FROM users WHERE username=? AND status_akun='aktif' LIMIT 1");
|
|
$stmt->bind_param('s', $username);
|
|
$stmt->execute();
|
|
$user = $stmt->get_result()->fetch_assoc();
|
|
|
|
// password_verify() digunakan agar password tidak disimpan plain text.
|
|
if ($user && password_verify($password, $user['password'])) {
|
|
$_SESSION['user_id'] = (int) $user['id'];
|
|
$_SESSION['nama'] = $user['nama'];
|
|
$_SESSION['role'] = $user['role'];
|
|
header('Location: dashboard.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">
|
|
<title>Login - WebGIS Poverty Mapping</title>
|
|
<style>
|
|
*{box-sizing:border-box} body{margin:0;min-height:100vh;font-family:Arial,sans-serif;background:linear-gradient(135deg,#0f766e,#0f172a);display:flex;align-items:center;justify-content:center;padding:20px}.card{width:100%;max-width:410px;background:#fff;border-radius:18px;box-shadow:0 18px 45px rgba(0,0,0,.25);padding:28px}.brand{display:flex;gap:12px;align-items:center;margin-bottom:18px}.logo{width:46px;height:46px;border-radius:13px;background:#0f766e;color:white;display:flex;align-items:center;justify-content:center;font-size:24px}h1{font-size:22px;margin:0;color:#0f172a}.muted{color:#64748b;font-size:13px;margin-top:4px}.fg{margin:14px 0}.fg label{font-weight:700;font-size:13px;color:#334155;display:block;margin-bottom:6px}.fg input{width:100%;padding:12px;border:1px solid #cbd5e1;border-radius:10px;font-size:14px}.btn{width:100%;padding:12px;border:0;border-radius:10px;background:#0f766e;color:white;font-weight:700;cursor:pointer}.err{background:#fee2e2;color:#991b1b;padding:10px;border-radius:10px;font-size:13px;margin:10px 0}.links{text-align:center;margin-top:15px;font-size:13px}.links a{color:#0f766e;text-decoration:none;font-weight:700}.demo{background:#f8fafc;border:1px solid #e2e8f0;padding:10px;border-radius:10px;font-size:12px;color:#475569;margin-top:14px}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="card">
|
|
<div class="brand"><div class="logo">🗺️</div><div><h1>WebGIS Poverty Mapping</h1><div class="muted">Manajemen bantuan/zakat berbasis lokasi</div></div></div>
|
|
<?php if($error): ?><div class="err"><?= htmlspecialchars($error) ?></div><?php endif; ?>
|
|
<form method="post">
|
|
<div class="fg"><label>Username</label><input name="username" required autofocus></div>
|
|
<div class="fg"><label>Password</label><input name="password" type="password" required></div>
|
|
<button class="btn">Login</button>
|
|
</form>
|
|
<div class="links">Belum punya akun penerima? <a href="register.php">Registrasi</a></div>
|
|
<div class="demo">Akun awal:<br>username <b>superadmin</b><br>password <b>password</b><br><br><b>Catatan:</b> registrasi hanya untuk penerima. Akun admin rumah ibadah dibuat oleh super admin dari dashboard.</div>
|
|
</div>
|
|
</body>
|
|
</html>
|