80 lines
3.8 KiB
HTML
80 lines
3.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="id">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>SIG Bansos - Login</title>
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
<style>
|
|
body { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; display: flex; align-items: center; }
|
|
.login-card { background: white; border-radius: 15px; padding: 40px; box-shadow: 0 20px 40px rgba(0,0,0,0.3); max-width: 400px; width: 100%; }
|
|
.login-card h3 { text-align: center; margin-bottom: 30px; color: #333; }
|
|
.btn-login { width: 100%; padding: 10px; font-size: 16px; }
|
|
.error-msg { display: none; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-4">
|
|
<div class="login-card">
|
|
<h3><i class="fas fa-map-marked-alt"></i> SIG Bansos</h3>
|
|
<div class="alert alert-danger error-msg" id="errorMsg"></div>
|
|
<form id="loginForm">
|
|
<div class="mb-3">
|
|
<label class="form-label">Username</label>
|
|
<input type="text" class="form-control" id="username" required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label">Password</label>
|
|
<input type="password" class="form-control" id="password" required>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary btn-login">
|
|
<i class="fas fa-sign-in-alt"></i> Login
|
|
</button>
|
|
</form>
|
|
<div class="text-center mt-3">
|
|
<a href="/WEBPOVERTYSIGUAS/sig-bansos/PENGGUNA%20UMUM.html" class="text-muted">Lihat sebagai Pengguna Umum</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.getElementById('loginForm').addEventListener('submit', async function(e) {
|
|
e.preventDefault();
|
|
|
|
const username = document.getElementById('username').value;
|
|
const password = document.getElementById('password').value;
|
|
|
|
try {
|
|
const response = await fetch('/WEBPOVERTYSIGUAS/sig-jalan/api_login.php?action=login', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({username, password})
|
|
});
|
|
|
|
const result = await response.json();
|
|
|
|
if (result.success) {
|
|
sessionStorage.setItem('user', JSON.stringify(result.data));
|
|
|
|
if (result.data.role === 'admin') {
|
|
window.location.href = '/WEBPOVERTYSIGUAS/sig-bansos/DASHBOARD%20ADMIN.html';
|
|
} else {
|
|
window.location.href = '/WEBPOVERTYSIGUAS/sig-bansos/PENGGUNA%20UMUM.html';
|
|
}
|
|
} else {
|
|
document.getElementById('errorMsg').style.display = 'block';
|
|
document.getElementById('errorMsg').textContent = result.message;
|
|
}
|
|
} catch (error) {
|
|
document.getElementById('errorMsg').style.display = 'block';
|
|
document.getElementById('errorMsg').textContent = 'Gagal terhubung ke server';
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |