Initial commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* koneksi.php — Koneksi Database MySQL
|
||||
* WebGIS BantSOSial Pontianak
|
||||
*
|
||||
* Ubah kredensial sesuai konfigurasi server lokal Anda.
|
||||
*/
|
||||
|
||||
define('DB_HOST', 'localhost');
|
||||
define('DB_USER', 'root'); // Ganti sesuai MySQL user Anda
|
||||
define('DB_PASS', ''); // Ganti sesuai password MySQL Anda
|
||||
define('DB_NAME', 'webgis_bansos');
|
||||
|
||||
// Buat koneksi
|
||||
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
||||
|
||||
// Cek error koneksi
|
||||
if ($conn->connect_error) {
|
||||
http_response_code(500);
|
||||
die(json_encode([
|
||||
'success' => false,
|
||||
'message' => 'Koneksi database gagal: ' . $conn->connect_error
|
||||
]));
|
||||
}
|
||||
|
||||
// Set charset UTF-8
|
||||
$conn->set_charset('utf8mb4');
|
||||
|
||||
// Header JSON untuk semua response
|
||||
header('Content-Type: application/json');
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
|
||||
header('Access-Control-Allow-Headers: Content-Type');
|
||||
Reference in New Issue
Block a user