35604-vm/api/delete_recipe.php
Flatlogic Bot 24d0513664 2
2025-11-09 21:38:45 +00:00

25 lines
590 B
PHP

<?php
header('Content-Type: application/json');
require_once __DIR__ . '/../db/config.php';
$data = json_decode(file_get_contents('php://input'), true);
if (!$data || !isset($data['id'])) {
echo json_encode(['success' => false, 'error' => 'Invalid input. Recipe ID is missing.']);
exit;
}
$recipeId = $data['id'];
$pdo = db();
try {
$stmt = $pdo->prepare("DELETE FROM recipes WHERE id = ?");
$stmt->execute([$recipeId]);
echo json_encode(['success' => true]);
} catch (PDOException $e) {
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
}