Project UAS Sistem Informasi Geografis (SIG)
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
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);
|
||||
$jenis_bantuan = $data['jenis_bantuan'] ?? '';
|
||||
|
||||
if ($id === 0 || $jenis_bantuan === '') {
|
||||
echo json_encode(["message"=>"Parameter tidak valid"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("UPDATE penduduk_miskin SET jenis_bantuan=? WHERE id=?");
|
||||
$stmt->bind_param("si", $jenis_bantuan, $id);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(["message"=>"Berhasil"]);
|
||||
} else {
|
||||
echo json_encode(["message"=>"Gagal", "error"=>$stmt->error]);
|
||||
}
|
||||
$stmt->close(); $conn->close();
|
||||
?>
|
||||
Reference in New Issue
Block a user