22 lines
649 B
PHP
22 lines
649 B
PHP
<?php
|
|
// otak_spbu/api_hapus_spbu.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)) {
|
|
try {
|
|
$stmt = $conn->prepare("DELETE FROM spbu_markers WHERE id = :id");
|
|
$stmt->bindValue(':id', $data->id, PDO::PARAM_INT);
|
|
|
|
if($stmt->execute()) {
|
|
echo json_encode(["pesan" => "SPBU berhasil dihapus."]);
|
|
}
|
|
} catch(PDOException $e) {
|
|
http_response_code(500);
|
|
echo json_encode(["error" => $e->getMessage()]);
|
|
}
|
|
}
|
|
?>
|