delete.php 491 B

1234567891011121314151617181920212223
  1. <?php
  2. include '../connection.php';
  3. try {
  4. $params = json_decode(file_get_contents('php://input'));
  5. $statement = $db->prepare("delete from task where id = $params->id");
  6. if(!$statement->execute()) {
  7. throw new Exception(implode(', ', $statement->errorInfo()));
  8. }
  9. $jsonResult = array('success' => true);
  10. } catch(Exception $e) {
  11. $jsonResult = array(
  12. 'success' => false,
  13. 'message' => $e->getMessage()
  14. );
  15. }
  16. echo json_encode($jsonResult);
  17. ?>