-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_survey.php
executable file
·81 lines (69 loc) · 1.97 KB
/
_survey.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
function q($value)
{
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
if (!is_numeric($value)) {
$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
}
function submit_survey()
{
mysql_query("INSERT INTO survey_submissions2006(submitter_id) VALUES (".q($_POST['form']).");");
$id = mysql_insert_id();
foreach($_POST as $k => $v) {
if (!empty($v) && (substr($k, 0, 2) == 'q_')) {
$qid = substr($k, 2);
$qnum = $_POST["qn_$qid"];
mysql_query("INSERT INTO survey_responses2006(submission_id, question_id, question_number, response) VALUES (".q($id).", ".q($qid).", ".q($qnum).", ".q($v).");");
}
}
}
$g_question_number = 1;
function start_form()
{
echo "<form method=\"post\" action=\"\"><input type=\"hidden\" name=\"form\" value=\"".htmlspecialchars($_REQUEST['form'])."\"><ol>\n";
}
function end_form()
{
echo "</ol><a name=\"end\"><input type=\"submit\" name=\"submit\" value=\"Submit survey\"></a></form>\n";
}
function survey_section($intro)
{
echo "<p><b>$intro</b></p>\n";
}
function long_question($name, $question, $rows = 5)
{
global $g_question_number;
echo "<li>$question<br>\n<input type=\"hidden\" name=\"qn_$name\" value=\"$g_question_number\"><textarea name=\"q_$name\" rows=\"$rows\" cols=\"72\"></textarea></li>\n";
$g_question_number++;
}
function short_question($name, $question)
{
long_question($name, $question, 1);
}
function multi_question_core($name, $choices)
{
global $g_question_number;
echo "<input type=\"hidden\" name=\"qn_$name\" value=\"$g_question_number\"><select name=\"q_$name\">\n";
foreach ($choices as $c) {
echo "<option value=\"$c\">$c</option>\n";
}
echo "</select>\n";
$g_question_number++;
}
function multi_question($name, $question, $choices)
{
echo "<li>$question<br>\n";
multi_question_core($name, $choices);
echo "</li>\n";
}
function multi_question_before($name, $question, $choices)
{
echo "<li>";
multi_question_core($name, $choices);
echo " $question</li>\n";
}
?>