Files
SIG_WEBGIS_Nur_Ichsanul_Alif/login.php
T
2026-06-13 12:01:09 +07:00

108 lines
3.6 KiB
PHP

<?php
session_start();
require_once 'config/db.php';
if (isset($_SESSION['user_id'])) {
header("Location: dashboard.php");
exit;
}
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = trim($_POST['username'] ?? '');
$password = $_POST['password'] ?? '';
if ($username && $password) {
$pdo = getDB();
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = ? LIMIT 1");
$stmt->execute([$username]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password_hash'])) {
$_SESSION['user_id'] = $user['id'];
$_SESSION['username'] = $user['username'];
$_SESSION['role'] = $user['role'];
header("Location: dashboard.php");
exit;
} else {
$error = 'Username atau password salah!';
}
} else {
$error = 'Silakan isi username dan password!';
}
}
?>
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SinergiSpasial | Login</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Poppins', sans-serif;
background-color: #0b0f19;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background-image: linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
background-size: 30px 30px;
}
.login-box {
background: rgba(20, 27, 45, 0.8);
backdrop-filter: blur(10px);
padding: 40px;
border-radius: 15px;
border: 1px solid rgba(255, 255, 255, 0.1);
width: 100%;
max-width: 400px;
text-align: center;
}
h2 { margin-top: 0; color: #00d2ff; }
.form-group { margin-bottom: 20px; text-align: left; }
label { display: block; margin-bottom: 8px; font-size: 0.9rem; color: #94a3b8; }
input {
width: 100%; padding: 12px;
border-radius: 8px; border: 1px solid rgba(255,255,255,0.2);
background: rgba(0,0,0,0.2); color: #fff; font-size: 1rem; box-sizing: border-box;
}
input:focus { outline: none; border-color: #00d2ff; }
button {
width: 100%; padding: 12px; background: linear-gradient(45deg, #3a7bd5, #00d2ff);
border: none; border-radius: 30px; color: #fff; font-size: 1rem; font-weight: 600; cursor: pointer;
}
.error { color: #f43f5e; margin-bottom: 20px; font-size: 0.9rem; }
.info { font-size: 0.8rem; color: #94a3b8; margin-top: 20px; }
</style>
</head>
<body>
<div class="login-box">
<h2>Login SinergiSpasial</h2>
<?php if ($error): ?><div class="error"><?= $error ?></div><?php endif; ?>
<form method="POST">
<div class="form-group">
<label>Username</label>
<input type="text" name="username" required>
</div>
<div class="form-group">
<label>Password</label>
<input type="password" name="password" required>
</div>
<button type="submit">Masuk ke Dashboard</button>
</form>
<div class="info">
<p>Akses Admin: <b>admin</b> / <b>admin123</b></p>
<p>Akses Publik: <b>public</b> / <b>public123</b></p>
</div>
</div>
</body>
</html>