Handle missing table error gracefully in auth.php

This commit is contained in:
Nama Kamu
2026-06-11 15:59:27 +07:00
parent 454d2c12c0
commit d94a42bb6b
+3
View File
@@ -13,6 +13,9 @@ if ($aksi === 'login') {
$password = $_POST['password'] ?? '';
if (!$email || !$password) json_out(['error'=>'Email dan password wajib diisi'],400);
$stmt = $conn->prepare("SELECT u.*,r.nama AS role_nama FROM user u JOIN role r ON u.role_id=r.id WHERE u.email=? AND u.aktif=1 LIMIT 1");
if (!$stmt) {
json_out(['error' => 'Database error: ' . $conn->error], 500);
}
$stmt->bind_param('s',$email);
$stmt->execute();
$user = $stmt->get_result()->fetch_assoc();