Project UAS Sistem Informasi Geografis (SIG)
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
include 'db.php';
|
||||
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
if (!$data) {
|
||||
echo json_encode(["message" => "Data kosong"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = intval($data['id'] ?? 0);
|
||||
$radius = floatval($data['radius'] ?? 0);
|
||||
|
||||
if ($id <= 0 || $radius <= 0) {
|
||||
echo json_encode(["message" => "Parameter tidak valid"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Sesuaikan dengan batas slider di draw_sosial.js.
|
||||
if ($radius < 100 || $radius > 5000) {
|
||||
echo json_encode(["message" => "Radius harus berada di antara 100 sampai 5000 meter"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("UPDATE masjid SET radius = ?, radius_layanan = ? WHERE id = ?");
|
||||
if (!$stmt) {
|
||||
echo json_encode(["message" => "Gagal menyiapkan query", "error" => $conn->error]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt->bind_param("ddi", $radius, $radius, $id);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(["message" => "Berhasil", "radius" => $radius]);
|
||||
} else {
|
||||
echo json_encode(["message" => "Gagal", "error" => $stmt->error]);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
Reference in New Issue
Block a user