-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_poll.php
51 lines (37 loc) · 1.44 KB
/
edit_poll.php
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
43
44
45
46
47
48
49
50
51
<?php
include_once('database/connection.php');
include_once('database/polls.php');
include_once('database/questions.php');
include_once('database/answers.php');
include('lock.php');
include('templates/header.php');
include('templates/navbar.php');
// Validates form.
include('templates/validation/edit_poll_form_validation.php');
// If we don't have a form post, prepares form.
if(isset($_GET['id'])) {
$params = ['db' => $db, 'id' => $_GET['id']];
$result = getPollById($params);
$poll_id = $_GET['id'];
$descr = $result['description'];
$privacy = $result['public'];
$questions = getPollQuestions($params);
} else {
$_SESSION['message'] = "Poll not found.";
header("location: user.php");
}
?>
<form method="POST" action="edit_poll.php?id=<?= $poll_id ?>">
<input type="hidden" name="poll_id" value="<?= $poll_id; ?>" />
<input type="hidden" name="pollTitle" value="<?= $descr; ?>" />
<input type="hidden" name="public" value="<?= $privacy; ?>" />
<?php if(isset($questions) && (sizeof($questions) > 0)) { ?> <input type="hidden" name="question" value="<?php echo htmlentities(serialize($questions)); ?>" /> <?php } ?>
<?php
$_POST['poll_id'] = $poll_id;
$_POST['pollTitle'] = $descr;
$_POST['public'] = $privacy;
$_POST['question'] = $questions;
include('templates/editor/create_poll_editor.php');
?>
</form>
<?php include('templates/footer.php'); ?>