Files
UAS-SIG-WebGIS-Poverty-Mapping/save.php
T
2026-06-13 13:38:52 +07:00

31 lines
795 B
PHP

<?php
include 'db.php';
$data = json_decode(file_get_contents("php://input"), true);
$tipe = $data['tipe'];
$status = $data['status'] ?? '';
$nilai = $data['nilai'] ?? 0;
$geom = json_encode($data['geom']);
error_log("Save data: tipe=$tipe, status=$status, nilai=$nilai");
if($tipe == "jalan"){
$panjang = $nilai ? $nilai : 0;
$sql = "INSERT INTO data_unified (tipe, status, panjang, geom)
VALUES ('jalan', '$status', $panjang, '$geom')";
}
if($tipe == "parsil"){
$luas = $nilai ? $nilai : 0;
$sql = "INSERT INTO data_unified (tipe, status, luas, geom)
VALUES ('parsil', '$status', $luas, '$geom')";
}
if ($conn->query($sql) === TRUE) {
echo "Sukses";
} else {
echo "Error: " . $conn->error;
error_log("SQL Error: " . $conn->error);
}
?>