26 lines
577 B
PHP
26 lines
577 B
PHP
<?php
|
|
require_once 'db_config.php';
|
|
header('Content-Type: application/json');
|
|
|
|
$data = json_decode(file_get_contents('php://input'), true);
|
|
|
|
if (!$data || !isset($data['id'])) {
|
|
echo json_encode(['status' => 'error', 'message' => 'ID tidak ditemukan']);
|
|
exit;
|
|
}
|
|
|
|
$id = intval($data['id']);
|
|
|
|
$stmt = $conn->prepare("DELETE FROM warga WHERE id = ?");
|
|
$stmt->bind_param("i", $id);
|
|
|
|
if ($stmt->execute()) {
|
|
echo json_encode(['status' => 'success']);
|
|
} else {
|
|
echo json_encode(['status' => 'error', 'message' => $stmt->error]);
|
|
}
|
|
|
|
$stmt->close();
|
|
$conn->close();
|
|
?>
|