Memperbaiki penamaan folder dan menambahkan index.html sebagai landing page
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
// Pastikan nama database sudah benar
|
||||
$conn = new mysqli("localhost", "root", "", "webgis");
|
||||
|
||||
if ($conn->connect_error) {
|
||||
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Menangkap data JSON yang dikirim dari fetch() JavaScript
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
if ($data && isset($data['id'])) {
|
||||
$id = $data['id'];
|
||||
|
||||
// Sesuaikan nama tabel dengan screenshot phpMyAdmin Anda: rumah_prasejahtera
|
||||
$stmt = $conn->prepare("DELETE FROM rumah_prasejahtera WHERE id = ?");
|
||||
$stmt->bind_param("i", $id); // "i" berarti integer
|
||||
|
||||
if ($stmt->execute()) {
|
||||
// Cek apakah benar-benar ada baris yang terhapus di database
|
||||
if ($stmt->affected_rows > 0) {
|
||||
echo json_encode(["status" => "success"]);
|
||||
} else {
|
||||
// Jika ID tidak ditemukan di tabel
|
||||
echo json_encode(["status" => "error", "message" => "Data dengan ID $id tidak ditemukan di database."]);
|
||||
}
|
||||
} else {
|
||||
// Jika query MySQL gagal/error
|
||||
echo json_encode(["status" => "error", "message" => $stmt->error]);
|
||||
}
|
||||
$stmt->close();
|
||||
} else {
|
||||
// Jika JavaScript gagal mengirimkan ID
|
||||
echo json_encode(["status" => "error", "message" => "ID tidak diterima oleh server PHP."]);
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli('localhost', 'root', '', 'webgis');
|
||||
$result = $conn->query("SELECT * FROM rumah_prasejahtera");
|
||||
$data = [];
|
||||
while ($row = $result->fetch_assoc()) $data[] = $row;
|
||||
echo json_encode($data);
|
||||
?>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli("localhost", "root", "", "webgis");
|
||||
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
if ($data && isset($data['lat']) && isset($data['lng'])) {
|
||||
// Tangkap data
|
||||
$nama_kk = $data['nama_kk'];
|
||||
$penghasilan = $data['penghasilan'];
|
||||
$jumlah_anak = $data['jumlah_anak'];
|
||||
$umur_anak = $data['umur_anak'];
|
||||
$status_ortu = $data['status_ortu'];
|
||||
$ada_pensiun = $data['ada_pensiun'];
|
||||
$nominal_pensiun = $data['nominal_pensiun'];
|
||||
$ada_terusan = $data['ada_terusan'];
|
||||
$nominal_terusan = $data['nominal_terusan'];
|
||||
$keterangan = $data['keterangan'];
|
||||
$lat = $data['lat'];
|
||||
$lng = $data['lng'];
|
||||
|
||||
// Update Query (12 Parameter)
|
||||
$stmt = $conn->prepare("INSERT INTO rumah_prasejahtera
|
||||
(nama_kepala_keluarga, penghasilan, jumlah_anak, umur_anak, status_ortu, ada_pensiun, nominal_pensiun, ada_terusan, nominal_terusan, keterangan, lat, lng)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
|
||||
// PERBAIKAN DI SINI: Jumlah huruf (12) sekarang sudah pas dengan jumlah variabelnya (12)
|
||||
$stmt->bind_param("sdisssdsdsdd", $nama_kk, $penghasilan, $jumlah_anak, $umur_anak, $status_ortu, $ada_pensiun, $nominal_pensiun, $ada_terusan, $nominal_terusan, $keterangan, $lat, $lng);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(["status" => "success", "id" => $stmt->insert_id]);
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => $stmt->error]);
|
||||
}
|
||||
$stmt->close();
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => "Data tidak lengkap"]);
|
||||
}
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli('localhost', 'root', '', 'webgis');
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$stmt = $conn->prepare("UPDATE rumah_prasejahtera SET lat=?, lng=? WHERE id=?");
|
||||
$stmt->bind_param("ddi", $data['lat'], $data['lng'], $data['id']);
|
||||
echo $stmt->execute()
|
||||
? json_encode(['status' => 'success'])
|
||||
: json_encode(['status' => 'error']);
|
||||
?>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli('localhost', 'root', '', 'webgis');
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$stmt = $conn->prepare("DELETE FROM rumah_ibadah WHERE id = ?");
|
||||
$stmt->bind_param("i", $data['id']);
|
||||
echo $stmt->execute()
|
||||
? json_encode(['status' => 'success'])
|
||||
: json_encode(['status' => 'error']);
|
||||
?>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli('localhost', 'root', '', 'webgis');
|
||||
$result = $conn->query("SELECT * FROM rumah_ibadah");
|
||||
$data = [];
|
||||
while ($row = $result->fetch_assoc()) $data[] = $row;
|
||||
echo json_encode($data);
|
||||
?>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli('localhost', 'root', '', 'webgis');
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$stmt = $conn->prepare("INSERT INTO rumah_ibadah (nama_ibadah, jenis, radius_m, lat, lng) VALUES (?, ?, ?, ?, ?)");
|
||||
$stmt->bind_param("ssidd", $data['nama_ibadah'], $data['jenis'], $data['radius_m'], $data['lat'], $data['lng']);
|
||||
echo $stmt->execute()
|
||||
? json_encode(['status' => 'success', 'id' => $conn->insert_id])
|
||||
: json_encode(['status' => 'error']);
|
||||
?>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli('localhost', 'root', '', 'webgis');
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$stmt = $conn->prepare("UPDATE rumah_ibadah SET lat=?, lng=? WHERE id=?");
|
||||
$stmt->bind_param("ddi", $data['lat'], $data['lng'], $data['id']);
|
||||
echo $stmt->execute()
|
||||
? json_encode(['status' => 'success'])
|
||||
: json_encode(['status' => 'error']);
|
||||
?>
|
||||
Reference in New Issue
Block a user