Files
TUGAS-SIG/01/hapus_feature.php
T

29 lines
816 B
PHP

<?php
/**
* Kegunaan: Menghapus data secara permanen dari tabel yang relevan.
*/
header('Content-Type: application/json');
require 'koneksi.php';
$data = json_decode(file_get_contents("php://input"), true);
try {
if ($data['type'] === 'jalan') {
$stmt = $koneksi_pdo->prepare("DELETE FROM jalan WHERE id = ?");
}
else if ($data['type'] === 'persil') {
$stmt = $koneksi_pdo->prepare("DELETE FROM persil_tanah WHERE id = ?");
}
else if ($data['type'] === 'spbu') {
$stmt = $koneksi_pdo->prepare("DELETE FROM spbu WHERE id = ?");
}
if (isset($stmt)) {
$stmt->execute([$data['id']]);
}
echo json_encode(["status" => "success"]);
} catch (PDOException $e) {
echo json_encode(["status" => "error", "message" => $e->getMessage()]);
}
?>