rate_team.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * File for the team score modification.
  4. *
  5. * Implements an action function to be called from the {@see Controller}.
  6. *
  7. * @category Action
  8. */
  9. /**
  10. * Sets the score for a team.
  11. *
  12. * Reads the POST parameters looking for the following KEYS:
  13. * uid
  14. * team
  15. * score
  16. * Validates the data and sets the score.
  17. *
  18. * @return int 0 on success, negative values on error.
  19. * @category Action
  20. * @global resource Database connection.
  21. */
  22. function action(){
  23. global $db;
  24. $player = filter_input(INPUT_GET, 'uid');
  25. $team = filter_input(INPUT_GET, 'team');
  26. $score = intval(filter_input(INPUT_GET, 'score'));
  27. $statement = $db->prepare('UPDATE team SET score = :score WHERE uid = :uid AND id = :team;');
  28. $statement->bindValue(':score', $score);
  29. $statement->bindValue(':uid', $player);
  30. $statement->bindValue(':team', $team);
  31. $res = $statement->execute();
  32. return 0;
  33. }
  34. ?>