initial commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require_once __DIR__ . '/../koneksi.php';
|
||||
|
||||
$id = intval($_POST['id'] ?? 0);
|
||||
$nama = trim($_POST['nama'] ?? '');
|
||||
$status = trim($_POST['status'] ?? '');
|
||||
|
||||
// Jika ada geojson, update geometri juga
|
||||
if (isset($_POST['geojson'])) {
|
||||
$geojson = $_POST['geojson'];
|
||||
$luas = floatval($_POST['luas'] ?? 0);
|
||||
$sql = "UPDATE parsil_tanah SET nama = ?, status = ?, geojson = ?, luas = ? WHERE id = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("sssdi", $nama, $status, $geojson, $luas, $id);
|
||||
} else {
|
||||
// Hanya update info
|
||||
$sql = "UPDATE parsil_tanah SET nama = ?, status = ? WHERE id = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("ssi", $nama, $status, $id);
|
||||
}
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(['status' => 'success']);
|
||||
} else {
|
||||
echo json_encode(['status' => 'error', 'message' => $stmt->error]);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user