25 lines
860 B
PHP
25 lines
860 B
PHP
<?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; }
|
|
|
|
$nama = $data['nama'] ?? '';
|
|
$pic = $data['pic'] ?? '';
|
|
$radius = $data['radius'] ?? 500;
|
|
$lat = $data['lat'] ?? 0;
|
|
$lng = $data['lng'] ?? 0;
|
|
|
|
if ($nama==='' || $pic==='') { echo json_encode(["message"=>"Field tidak lengkap"]); exit; }
|
|
|
|
$stmt = $conn->prepare("INSERT INTO masjid (nama, pic, radius, latitude, longitude, radius_layanan) VALUES (?,?,?,?,?,?)");
|
|
$stmt->bind_param("ssdddd", $nama, $pic, $radius, $lat, $lng, $radius);
|
|
|
|
if ($stmt->execute()) {
|
|
echo json_encode(["message"=>"Berhasil", "id"=>$stmt->insert_id]);
|
|
} else {
|
|
echo json_encode(["message"=>"Gagal", "error"=>$stmt->error]);
|
|
}
|
|
$stmt->close(); $conn->close();
|
|
?>
|