Initial commit: Upload project WebGIS pemetaan sosial
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Konfigurasi Database (Sesuaikan dengan milik Anda)
|
||||
$host = "localhost";
|
||||
$user = "root";
|
||||
$pass = "";
|
||||
$db = "webgis"; // UBAH INI
|
||||
|
||||
$conn = new mysqli($host, $user, $pass, $db);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
if ($data && isset($data['id']) && isset($data['lat']) && isset($data['lng'])) {
|
||||
$id = $data['id'];
|
||||
$lat = $data['lat'];
|
||||
$lng = $data['lng'];
|
||||
|
||||
// Update lat dan lng berdasarkan ID
|
||||
$stmt = $conn->prepare("UPDATE spbu_point SET lat = ?, lng = ? WHERE id = ?");
|
||||
$stmt->bind_param("ddi", $lat, $lng, $id);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(["status" => "success", "message" => "Lokasi berhasil diperbarui"]);
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => "Gagal update lokasi: " . $stmt->error]);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => "Data tidak lengkap"]);
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
Reference in New Issue
Block a user