Files
D1041231084_WebGis_GeoPoverty/test.html
T
2026-06-11 21:20:59 +07:00

49 lines
2.0 KiB
HTML

<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"><title>Test Login</title></head>
<body style="background:#111;color:#fff;font-family:sans-serif;padding:30px">
<h2>🔧 Test Login GeoSosial</h2>
<p>Username: <input id="u" value="admin" style="padding:6px;width:200px"></p>
<p>Password: <input id="p" type="password" value="admin123" style="padding:6px;width:200px"></p>
<button onclick="go()" style="padding:10px 20px;background:#1a5fff;color:#fff;border:none;border-radius:6px;font-size:16px;cursor:pointer">LOGIN TEST</button>
<pre id="out" style="background:#000;padding:16px;margin-top:20px;border-radius:8px;color:#0f0;white-space:pre-wrap"></pre>
<script>
function log(msg){ document.getElementById('out').textContent += msg + '\n'; }
async function go(){
document.getElementById('out').textContent = '';
log('Klik terdeteksi!');
log('URL: ' + window.location.href);
const u = document.getElementById('u').value;
const p = document.getElementById('p').value;
log('Username: ' + u + ', Password: ' + p);
log('Mengirim fetch ke: api/auth.php?action=login');
try {
const res = await fetch('api/auth.php?action=login', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({username: u, password: p})
});
log('HTTP Status: ' + res.status);
const raw = await res.text();
log('Raw response: [' + raw + ']');
try {
const json = JSON.parse(raw);
log('JSON parse: OK');
log('success: ' + json.success);
log('message: ' + json.message);
if(json.success) log('✅ LOGIN BERHASIL! Role: ' + json.data.role);
else log('❌ LOGIN GAGAL: ' + json.message);
} catch(e) {
log('❌ JSON parse GAGAL: ' + e.message);
log('Response tidak valid JSON - ada PHP error di output!');
}
} catch(e) {
log('❌ Fetch error: ' + e.message);
log('Kemungkinan: server tidak jalan, CORS, atau network error');
}
}
log('Halaman siap. Tekan tombol LOGIN TEST.');
</script>
</body>
</html>