Files
WebGIS_Project/04/edit.php
T
2026-06-11 15:23:09 +07:00

25 lines
590 B
PHP

<?php
include 'koneksi.php';
$id = (int)($_POST['id'] ?? 0);
$nama = trim($_POST['nama'] ?? '');
$wa = trim($_POST['wa'] ?? '');
$status = $_POST['status'] ?? 'no';
if (!in_array($status, ['yes', 'no'], true)) {
http_response_code(400);
echo "Status tidak valid";
exit;
}
try {
$stmt = $conn->prepare("UPDATE spbu SET nama_spbu=?, no_wa=?, status=? WHERE id=?");
$stmt->bind_param('sssi', $nama, $wa, $status, $id);
$stmt->execute();
echo "success";
} catch (mysqli_sql_exception $e) {
http_response_code(500);
echo "error: " . $e->getMessage();
}
?>