summary refs log tree commit diff stats
path: root/admin/newPoll.php
diff options
context:
space:
mode:
Diffstat (limited to 'admin/newPoll.php')
-rw-r--r--admin/newPoll.php104
1 files changed, 104 insertions, 0 deletions
diff --git a/admin/newPoll.php b/admin/newPoll.php new file mode 100644 index 0000000..0373980 --- /dev/null +++ b/admin/newPoll.php
@@ -0,0 +1,104 @@
1<?php
2/*
3 444444444
4 4::::::::4
5 4:::::::::4
6 4::::44::::4
7 4::::4 4::::4 Four Island
8 4::::4 4::::4
9 4::::4 4::::4 Written and maintained by Starla Insigna
104::::444444::::444
114::::::::::::::::4 admin/newPoll.php
124444444444:::::444
13 4::::4 Please do not use, reproduce or steal the
14 4::::4 contents of this file without explicit
15 4::::4 permission from Hatkirby.
16 44::::::44
17 4::::::::4
18 4444444444
19*/
20
21if (!defined('S_INCLUDE_FILE')) {define('S_INCLUDE_FILE',1);}
22
23require('headerproc.php');
24
25$category = 'polls';
26$pageaid = 'newpoll';
27
28$template = new FITemplate('admin/writePoll');
29
30if (isset($_GET['submit']))
31{
32 if (empty($_POST['question']))
33 {
34 $errors[] = array( 'field' => 'question',
35 'text' => 'Question is a required field');
36 }
37
38 if (empty($_POST['option1']))
39 {
40 $errors[] = array( 'field' => 'option1',
41 'text' => 'Option 1 is a required field');
42 }
43
44 if (empty($_POST['option2']))
45 {
46 $errors[] = array( 'field' => 'option2',
47 'text' => 'Option 2 is a required field');
48 }
49
50 if (empty($_POST['option3']))
51 {
52 $errors[] = array( 'field' => 'option3',
53 'text' => 'Option 3 is a required field');
54 }
55
56 if (empty($_POST['option4']))
57 {
58 $errors[] = array( 'field' => 'option4',
59 'text' => 'Option 4 is a required field');
60 }
61
62 if (isset($errors))
63 {
64 $template->adds_block('ISERROR',array('exi'=>1));
65
66 $eid = 0;
67 foreach ($errors as $error)
68 {
69 $template->adds_block('ERROR', array( 'ID' => $eid,
70 'TEXT' => $error['text']));
71 $template->add('IS' . strtoupper($error['field']) . 'ERROR', ' error');
72 $template->adds_block(strtoupper($error['field']) . 'ERROR', array( 'ID' => $eid,
73 'TEXT' => $error['text']));
74
75 $eid++;
76 }
77
78 $template->add('TITLE', 'New Poll');
79 $template->add('ACTION', '/admin/newPoll.php?submit=');
80 } else {
81 $inspoll = "INSERT INTO polloftheweek (question,option1,option2,option3,option4,text) VALUES (\"" . mysql_real_escape_string($_POST['question']) . "\",\"" . mysql_real_escape_string($_POST['option1']) . "\",\"" . mysql_real_escape_string($_POST['option2']) . "\",\"" . mysql_real_escape_string($_POST['option3']) . "\",\"" . mysql_real_escape_string($_POST['option4']) . "\",\"" . mysql_real_escape_string($_POST['text']) . "\")";
82 $inspoll2 = mysql_query($inspoll);
83
84 $id = mysql_insert_id();
85
86 $template->add('QUESTIONVALUE', $_POST['question']);
87 $template->add('OPTION1VALUE', $_POST['option1']);
88 $template->add('OPTION2VALUE', $_POST['option2']);
89 $template->add('OPTION3VALUE', $_POST['option3']);
90 $template->add('OPTION4VALUE', $_POST['option4']);
91 $template->add('TEXTVALUE', $_POST['text']);
92
93 $template->add('TITLE', 'Edit Poll');
94 $template->add('ACTION', '/admin/editPoll.php?id=' . $id . '&amp;submit=');
95 $template->adds_block('FLASH', array('TEXT' => 'Your poll has been sucessfully created. <a href="/poll/' . $id . '.php">View poll</a>.'));
96 }
97} else {
98 $template->add('TITLE', 'New Poll');
99 $template->add('ACTION', '/admin/newPoll.php?submit=');
100}
101
102$template->display();
103
104?>