update.php 558 B

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