33 lines
837 B
PHP
33 lines
837 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
ini_set('display_errors', 0);
|
|
|
|
include 'db.php';
|
|
|
|
if (!isset($conn) || $conn->connect_error) {
|
|
http_response_code(500);
|
|
echo json_encode(['success' => false, 'error' => 'Database connection failed']);
|
|
exit;
|
|
}
|
|
|
|
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
|
|
$tipe = isset($_POST['tipe']) ? $conn->real_escape_string($_POST['tipe']) : '';
|
|
|
|
if ($id <= 0) {
|
|
http_response_code(400);
|
|
echo json_encode(['success' => false, 'error' => 'ID tidak valid']);
|
|
exit;
|
|
}
|
|
|
|
$where = "id=$id";
|
|
if ($tipe !== '') {
|
|
$where .= " AND tipe='$tipe'";
|
|
}
|
|
|
|
if ($conn->query("DELETE FROM data_unified WHERE $where") === TRUE) {
|
|
echo json_encode(['success' => true]);
|
|
} else {
|
|
http_response_code(400);
|
|
echo json_encode(['success' => false, 'error' => $conn->error]);
|
|
}
|
|
?>
|