« Back to History
delete_task.php
|
20260920_164915.php
Initial Domain Snapshot
Copy Code
<?php declare(strict_types=1); require_once __DIR__ . '/db.php'; if ($_SERVER['REQUEST_METHOD'] !== 'POST') { sendJsonResponse([ 'success' => false, 'message' => 'Invalid request method.', 'data' => new stdClass(), ], 405); } $input = array_merge($_POST, getJsonInput()); $taskId = (int) ($input['id'] ?? 0); if ($taskId <= 0) { sendJsonResponse([ 'success' => false, 'message' => 'Task id is required.', 'data' => new stdClass(), ], 422); } try { $connection = getDatabaseConnection(); $statement = $connection->prepare('DELETE FROM pull_tasks WHERE id = :id'); $statement->execute([':id' => $taskId]); if ($statement->rowCount() === 0) { sendJsonResponse([ 'success' => false, 'message' => 'Task not found.', 'data' => new stdClass(), ], 404); } sendJsonResponse([ 'success' => true, 'message' => 'Task deleted', 'data' => [ 'id' => $taskId, ], ]); } catch (Throwable $exception) { sendJsonResponse([ 'success' => false, 'message' => $exception->getMessage(), 'data' => new stdClass(), ], 500); }