initial commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
// Set header JSON untuk semua response
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$host = 'localhost';
|
||||
$user = 'root';
|
||||
$password = ''; // Pastikan password MySQL Anda
|
||||
$database = 'webgis';
|
||||
|
||||
try {
|
||||
// Buat koneksi
|
||||
$conn = new mysqli($host, $user, $password, $database);
|
||||
|
||||
// Cek koneksi
|
||||
if ($conn->connect_error) {
|
||||
throw new Exception("Koneksi gagal: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Set charset
|
||||
$conn->set_charset("utf8");
|
||||
|
||||
} catch (Exception $e) {
|
||||
// Jika error, tetap kembalikan JSON
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'message' => $e->getMessage()
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user