Beispiel #1
0
 //print_r($db->errorInfo());
 //adds the poll
 if ($title != '') {
     $stmt = $db->prepare('INSERT INTO poll(id,title,userId, titleHash, groupId) VALUES (?,?,?,?,?)');
     /*$titleHash = create_hash($title);*/
     $titleHash = md5('poll' . $title);
     $stmt->execute(array(NULL, $title, $userId, $titleHash, $groupId));
     //print_r($db->errorInfo()); echo '<br>';
 }
 //else echo 'titleVazio<br>';
 //verifies if all the options are filled
 foreach ($options as $option) {
     if ($option == '') {
         //echo 'optionVazia<br>';
     } else {
         $poll = getPollByTitle($title);
         $poll_id = $poll['id'];
         //echo 'pollId = '.$poll_id.'<br>';
         //echo 'option = '.$option.'<br>';
         //console.log( 'heelo 1');
         if ($option != '') {
             $optionT = htmlspecialchars($option);
             $db->exec("INSERT INTO pollOption VALUES(NULL,'{$poll_id}', '{$optionT}', 0)");
             //print_r($db->errorInfo());
             //echo '<br>';
         }
     }
 }
 //imagens
 //echo 'pre';
 if (isset($_FILES['image']['name']) && isset($_FILES['image']['type']) && isset($_FILES['image']['size']) && isset($_FILES['image']['tmp_name'])) {
Beispiel #2
0
function getPollOptions($title)
{
    global $db;
    $poll_id = getPollByTitle($title)['id'];
    $stmt = $db->prepare('SELECT * FROM pollOption WHERE poll_id = ?');
    $stmt->execute(array($poll_id));
    $result = $stmt->fetchAll();
    return $result;
}