Files
anjuma-dashboard/api/finance_expenses_delete.php
2026-07-22 01:12:45 +02:00

18 lines
569 B
PHP

<?php
require_once "../config/config.php";
header('Content-Type: application/json; charset=utf-8');
try {
if ($_SERVER['REQUEST_METHOD'] !== 'POST') throw new RuntimeException('Method not allowed');
$id = (int)($_POST['id'] ?? 0);
if ($id <= 0) throw new RuntimeException('id fehlt');
$stmt = $pdo->prepare("DELETE FROM finance_expenses WHERE id=:id");
$stmt->execute([':id'=>$id]);
echo json_encode(['ok'=>true], JSON_UNESCAPED_UNICODE);
} catch (Throwable $e) {
http_response_code(400);
echo json_encode(['ok'=>false,'error'=>$e->getMessage()]);
}