process_poll_results.php 579 B

123456789101112131415161718192021222324
  1. <?php
  2. require_once("./common.php");
  3. $poll_id = $_GET['poll_id'];
  4. $name = $_POST['name'];
  5. $other = urlencode($_POST['other']);
  6. $value = 0;
  7. foreach ($_POST['choice'] as $choice){
  8. $value += $choice;
  9. }
  10. $query = sprintf("INSERT INTO results (poll_id, name, choice, other) VALUES ('%s' , '%s', '%s', '%s');",
  11. mysql_real_escape_string($poll_id),
  12. mysql_real_escape_string($name),
  13. mysql_real_escape_string($value),
  14. mysql_real_escape_string($other)
  15. );
  16. mysql_query($query);
  17. header("Location: poll.php?poll_id=" . $_GET['poll_id']);
  18. ?>