27 lines
676 B
PHP
27 lines
676 B
PHP
<?php
|
|
require_once 'auth.php';
|
|
require_write_access_json();
|
|
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);
|
|
$geom = $data['geom'] ?? '';
|
|
$panjang = $data['panjang'] ?? 0;
|
|
|
|
$stmt = $conn->prepare("UPDATE jalan SET geom = ?, panjang = ? WHERE id = ?");
|
|
$stmt->bind_param("sdi", $geom, $panjang, $id);
|
|
|
|
if ($stmt->execute()) {
|
|
echo json_encode(["message" => "Berhasil diupdate"]);
|
|
} else {
|
|
echo json_encode(["message" => "Gagal update", "error" => $stmt->error]);
|
|
}
|
|
?>
|