A simple system for creating multiple-choice questions for an audience to answer on their phones. Responses are tallied and displayed in real-time. https://openquestion.netsyms.com

vote.php 585B

123456789101112131415161718192021222324
  1. <?php
  2. require_once __DIR__ . "/required.php";
  3. $qid = $VARS['qid'];
  4. $aid = $VARS['aid'];
  5. $code = $database->get('questions', 'qcode', ['qid' => $qid]);
  6. if (!$database->has('answers', ["AND" => ['qid' => $qid, 'aid' => $aid]])) {
  7. header("Location: ./r/$code/error");
  8. die();
  9. }
  10. if ($_SESSION['voted'][$qid] === true) {
  11. header("Location: ./r/$code/dejavu");
  12. die();
  13. }
  14. $database->insert("responses", ['qid' => $qid, 'aid' => $aid, 'timestamp' => date('Y-m-d H:i:s'), 'name' => $_SESSION['name']]);
  15. $_SESSION['voted'][$qid] = true;
  16. header("Location: ./r/$code/thanks");