Repository navigation
Expand file tree
/
Copy pathsubmit_poll.php
More file actions
42 lines (35 loc) · 1.69 KB
/
Copy pathsubmit_poll.php
File metadata and controls
42 lines (35 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
echo "<h1>Submit poll</h1><hr><br>";
if(isset($_SESSION['loggedin'])){
require_once('php/_conn.php');
require_once('php/_lib.php');
if(!isset($_POST['choices']) || !is_numeric($_POST['choices']) || $_POST['choices'] < 2){
$_POST['choices'] = 2;
}
else if($_POST['choices'] > 15){
echo "<p>Error: Max number of choices is 15.</p>";
$_POST['choices'] = 2;
}
//check if user is banned
$stmt = $pdo->prepare("SELECT lift FROM bans WHERE userid = ?;");
$stmt->bindValue(1, $_SESSION['userid']);
$stmt->execute();
$unban = $stmt->fetchColumn();
if(!((time() < strtotime($unban) + 14400) && isset($unban))){
echo '<form action="" method="post"><label for="choices">Enter number of choices: </label><input class="textfield" type="number" id="choices" name="choices" min="2" max="15"/>
<input type="submit" name="update" value="Update"/></form><br>
<div style="margin-left:5px;"><form action="php/poll_submitted.php?choices='.$_POST['choices'].'" method="post">
<label for="poll_question">The question: </label><br>
<input type="text" class="textfield" name="poll_question" id="poll_question" size="64"/><br>
<br><span>Choices</span><br>';
for($i=1;$i<$_POST['choices']+1;$i++){
echo '<label for="choice'.$i.'">'.$i.': </label>
<input type="text" class="textfield" name="choice'.$i.'" id="choice'.$i.'" size="32"/><br>';
}
echo '<br><input type="submit" name="submit" value="Submit"/></form></div>';
} else echo "<p>Banned users cannot submit a poll. Unban@: ".$unban."</p>";
} else echo "<p>You must login to submit an poll.</p>";
end:
$pdo = null;
$stmt = null;
?>