1st commit: version 1.0 WebGis-Pemetaan-Kemiskinan

This commit is contained in:
2026-06-03 02:09:03 +07:00
commit 313d2fd5a7
48 changed files with 4839 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
<?php
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
require_once '../koneksi.php';
$data = json_decode(file_get_contents("php://input"));
if (!empty($data->id_penduduk) && !empty($data->nik) && !empty($data->nama)) {
try {
$query = "INSERT INTO anggota_keluarga (id_penduduk, nik, nama_lengkap, tanggal_lahir, pendidikan_terakhir, pekerjaan)
VALUES (:id_penduduk, :nik, :nama, :lahir, :pendidikan, :pekerjaan)";
$stmt = $conn->prepare($query);
$pekerjaan = (!empty(trim($data->pekerjaan))) ? htmlspecialchars(strip_tags($data->pekerjaan)) : NULL;
$stmt->bindValue(':id_penduduk', $data->id_penduduk, PDO::PARAM_INT);
$stmt->bindValue(':nik', htmlspecialchars(strip_tags($data->nik)));
$stmt->bindValue(':nama', htmlspecialchars(strip_tags($data->nama)));
$stmt->bindValue(':lahir', $data->lahir);
$stmt->bindValue(':pendidikan', $data->pendidikan);
$stmt->bindValue(':pekerjaan', $pekerjaan);
if($stmt->execute()) {
echo json_encode(["pesan" => "Anggota keluarga berhasil ditambahkan."]);
}
} catch(PDOException $e) {
http_response_code(500); echo json_encode(["error" => "Error: " . $e->getMessage()]);
}
} else {
http_response_code(400); echo json_encode(["error" => "Data NIK dan Nama wajib diisi."]);
}
?>