delete_team.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * File for the team creation action.
  4. *
  5. * Implements an action function to be called from the {@see Controller}.
  6. *
  7. * @category Action
  8. */
  9. /**
  10. * Logs the user out and redirects to the login page.
  11. *
  12. * Reads the POST parameters looking for the following KEYS:
  13. * uid
  14. * area_type
  15. * area
  16. * stage
  17. * difficulty
  18. * ids
  19. * name
  20. * description
  21. * Validates the data and creates the team in the database.
  22. *
  23. * @return int 0 on success, negative values on error.
  24. * @category Action
  25. * @global resource Database connection.
  26. */
  27. function action(){
  28. global $db;
  29. $player = filter_input(INPUT_POST, 'uid');
  30. $id = filter_input(INPUT_POST, 'id');
  31. $statement = $db->prepare('DELETE FROM team WHERE uid = :uid AND id = :id;');
  32. $statement->bindValue(':uid', $player);
  33. $statement->bindValue(':id', $id);
  34. $res = $statement->execute();
  35. $statement = $db->prepare('DELETE FROM team_unit WHERE team = :id;');
  36. $statement->bindValue(':uid', $player);
  37. $statement->bindValue(':id', $id);
  38. $res = $statement->execute();
  39. return 0;
  40. }
  41. ?>