Initial commit - Fresh Clean Code
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
// config.php
|
||||
header('Content-Type: application/json');
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
|
||||
header('Access-Control-Allow-Headers: Content-Type');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||
http_response_code(200);
|
||||
exit();
|
||||
}
|
||||
|
||||
$host = 'localhost';
|
||||
$username = 'root';
|
||||
$password = '';
|
||||
$database = 'gis_management';
|
||||
$port = 3307; // Ganti ke 3307 jika XAMPP Anda menggunakan port 3307
|
||||
|
||||
$conn = new mysqli($host, $username, $password, $database, $port);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die(json_encode([
|
||||
'success' => false,
|
||||
'message' => 'Koneksi database gagal: ' . $conn->connect_error
|
||||
]));
|
||||
}
|
||||
|
||||
$conn->set_charset("utf8");
|
||||
|
||||
function sendResponse($success, $message, $data = null) {
|
||||
$response = [
|
||||
'success' => $success,
|
||||
'message' => $message
|
||||
];
|
||||
if ($data !== null) {
|
||||
$response['data'] = $data;
|
||||
}
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user