first commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
session_start();
|
||||
$role = isset($_SESSION['role']) ? $_SESSION['role'] : '';
|
||||
if ($role !== 'kemiskinan') { echo "unauthorized"; exit; }
|
||||
|
||||
include "koneksi.php";
|
||||
|
||||
$id = isset($_POST['id']) ? $conn->real_escape_string($_POST['id']) : '';
|
||||
$nama = $conn->real_escape_string($_POST['nama']);
|
||||
$tipe = $conn->real_escape_string($_POST['tipe']);
|
||||
$alamat = $conn->real_escape_string($_POST['alamat']);
|
||||
$lat = doubleval($_POST['lat']);
|
||||
$lng = doubleval($_POST['lng']);
|
||||
$radius = intval($_POST['radius']);
|
||||
|
||||
if (!empty($id)) {
|
||||
$sql = "UPDATE tb_tempat_ibadah SET
|
||||
nama = '$nama',
|
||||
tipe_ibadah = '$tipe',
|
||||
alamat = '$alamat',
|
||||
latitude = $lat,
|
||||
longitude = $lng,
|
||||
radius_meter = $radius
|
||||
WHERE id = '$id'";
|
||||
if ($conn->query($sql)) {
|
||||
echo "ok|" . $id;
|
||||
} else {
|
||||
echo "error";
|
||||
}
|
||||
} else {
|
||||
$sql = "INSERT INTO tb_tempat_ibadah
|
||||
(nama, tipe_ibadah, alamat, latitude, longitude, radius_meter)
|
||||
VALUES
|
||||
('$nama', '$tipe', '$alamat', $lat, $lng, $radius)";
|
||||
if ($conn->query($sql)) {
|
||||
echo "ok|" . $conn->insert_id;
|
||||
} else {
|
||||
echo "error";
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user