Probleem met poll antwoorden
Echter vind ik alleen maar polls waar men maar 1 antwoord kan invullen.
Kan iemand mij met dit probleem helpen?
Alvast bedankt...
deze checkboxjes geef je een naam zoals name="checkbox[]"
daarna lees je de waardes uit met een foreach loop.
succes!
Echter als ik er checkboxen van maak dan pakt hij slechts 1 stem.
Nu schijn je dat met stripslashes??? te moeten doen, maar zover gaat mijn kennis in PHP helaas niet...
Kan iemand mij helpen?
Zie hier mijn script:
Code (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?
include ("poll.txt");
if ($stem) {
$ip = fopen("ip.php", "r");
$contents = fread($ip, filesize("ip.php"));
$uip = $REMOTE_ADDR;
if (eregi("$uip", $contents)) {
echo "<font face=verdana size=2><b>Je hebt al gestemd! Bij de volgende poll mag je weer meedoen.</b></font><br><br>";
}
else {
$ip = fopen("ip.php", "a");
fputs ($ip, "<? //$REMOTE_ADDR ?>\n");
fclose ($ip);
$file = fopen("poll.txt", "w+");
fputs ($file, "<?\n");
fputs ($file, "\$antwoord[0] = \"$antwoord[0]\";\n");
fputs ($file, "\$antwoord[1] = \"$antwoord[1]\";\n");
fputs ($file, "\$antwoord[2] = \"$antwoord[2]\";\n");
fputs ($file, "\$antwoord[3] = \"$antwoord[3]\";\n");
fputs ($file, "\$antwoord[4] = \"$antwoord[4]\";\n");
fputs ($file, "\$antwoord[5] = \"$antwoord[5]\";\n");
fputs ($file, "\$antwoord[6] = \"$antwoord[6]\";\n");
fputs ($file, "\$antwoord[7] = \"$antwoord[7]\";\n");
fputs ($file, "\$antwoord[8] = \"$antwoord[8]\";\n");
fputs ($file, "\$antwoord[9] = \"$antwoord[9]\";\n\n");
if ($stem == $antwoord[0]) { $plusone = $votes[0] + 1; fputs ($file, "\$votes[0] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[0] = \"$votes[0]\";\n"); }
if ($stem == $antwoord[1]) { $plusone = $votes[1] + 1; fputs ($file, "\$votes[1] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[1] = \"$votes[1]\";\n"); }
if ($stem == $antwoord[2]) { $plusone = $votes[2] + 1; fputs ($file, "\$votes[2] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[2] = \"$votes[2]\";\n"); }
if ($stem == $antwoord[3]) { $plusone = $votes[3] + 1; fputs ($file, "\$votes[3] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[3] = \"$votes[3]\";\n"); }
if ($stem == $antwoord[4]) { $plusone = $votes[4] + 1; fputs ($file, "\$votes[4] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[4] = \"$votes[4]\";\n"); }
if ($stem == $antwoord[5]) { $plusone = $votes[5] + 1; fputs ($file, "\$votes[5] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[5] = \"$votes[5]\";\n"); }
if ($stem == $antwoord[6]) { $plusone = $votes[6] + 1; fputs ($file, "\$votes[6] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[6] = \"$votes[6]\";\n"); }
if ($stem == $antwoord[7]) { $plusone = $votes[7] + 1; fputs ($file, "\$votes[7] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[7] = \"$votes[7]\";\n"); }
if ($stem == $antwoord[8]) { $plusone = $votes[8] + 1; fputs ($file, "\$votes[8] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[8] = \"$votes[8]\";\n"); }
if ($stem == $antwoord[9]) { $plusone = $votes[9] + 1; fputs ($file, "\$votes[9] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[9] = \"$votes[9]\";\n"); }
$plusone = $totaal + 1;
fputs ($file, "\$totaal = \"$plusone\";\n");
fputs ($file, "\$vraag = \"$vraag\";\n");
fputs ($file, "?>");
fclose ($file);
echo "<meta http-equiv=refresh content=\"0; URL=$PHP_SELF";
if ($QUERY_STRING) { echo "?$QUERY_STRING\">"; } else { echo "\">"; }
} }
if ($vraag == "") { echo "<font face=verdana size=2><b>Er is geen poll open"; }
else {
$ip = fopen("ip.php", "r");
$contents = fread($ip, filesize("ip.php"));
$uip = $REMOTE_ADDR;
if (eregi("$uip", $contents)) {
echo " <font face=verdana size=2><b>$vraag</b> <font size=1>$totaal ";
if ($totaal == "1") { echo "stem"; } else { echo "stemmen"; }
echo " uitgebracht</font>\n\n";
echo "<table cellpadding=0 cellspacing=0 border=0>\n";
echo " <tr>\n";
echo " <td>\n";
for ($i = 0; $i < count($antwoord); $i++) {
if ($antwoord[$i] == "") { echo ""; } else {
echo " <font face=verdana size=1><b>$antwoord[$i]</b><br></font>\n";
} }
echo " </td>\n";
echo " <td valign=top>\n\n";
echo " <table cellpadding=0 cellspacing=0 border=0>\n";
for ($i = 0; $i < count($votes); $i++) {
if ($votes[$i] == "") { echo ""; } else {
echo " <tr>\n";
echo " <td align=right>\n";
echo " <font face=verdana size=1>";
echo (round(($votes[$i] / $totaal) * 100, 1));
echo "%</font>\n";
echo " </td>\n";
echo " <td>\n";
echo " <img style=\"border: 1 solid #000000\" src=balk.gif height=7 width=";
echo (round(($votes[$i] / $totaal) * 100, 1));
echo "><font face=verdana size=1> $votes[$i] ";
if ($votes[$i] == "1") { echo "stem"; } else { echo "stemmen"; }
echo "<br></font>\n";
echo " </td>\n";
echo " </tr>\n";
} }
echo " </table>\n\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n\n";
} else {
echo " <font face=verdana size=2><b>$vraag</b><br>\n\n";
echo "<table cellpadding=0 cellspacing=0 border=0>\n";
echo " <form name=form method=post><font face=verdana size=1>\n";
for ($i = 0; $i < count($antwoord); $i++) {
if ($antwoord[$i] == "") { echo ""; } else {
echo " <tr>\n";
echo " <td>\n";
echo " <input type=checkbox name=stem value=\"$antwoord[$i]\" id=\"$antwoord[$i]\">\n";
echo " </td>\n";
echo " <td>";
echo "<font size=1><label for=\"$antwoord[$i]\">$antwoord[$i]</label></font>";
echo "</td>\n";
echo " </tr>\n";
} }
echo "</table>\n\n";
echo "<input style=\"font-face: verdana; font-size: 9px\" type=submit value=\" Stem! \">\n";
echo "</form>\n\n";
} }
?>
include ("poll.txt");
if ($stem) {
$ip = fopen("ip.php", "r");
$contents = fread($ip, filesize("ip.php"));
$uip = $REMOTE_ADDR;
if (eregi("$uip", $contents)) {
echo "<font face=verdana size=2><b>Je hebt al gestemd! Bij de volgende poll mag je weer meedoen.</b></font><br><br>";
}
else {
$ip = fopen("ip.php", "a");
fputs ($ip, "<? //$REMOTE_ADDR ?>\n");
fclose ($ip);
$file = fopen("poll.txt", "w+");
fputs ($file, "<?\n");
fputs ($file, "\$antwoord[0] = \"$antwoord[0]\";\n");
fputs ($file, "\$antwoord[1] = \"$antwoord[1]\";\n");
fputs ($file, "\$antwoord[2] = \"$antwoord[2]\";\n");
fputs ($file, "\$antwoord[3] = \"$antwoord[3]\";\n");
fputs ($file, "\$antwoord[4] = \"$antwoord[4]\";\n");
fputs ($file, "\$antwoord[5] = \"$antwoord[5]\";\n");
fputs ($file, "\$antwoord[6] = \"$antwoord[6]\";\n");
fputs ($file, "\$antwoord[7] = \"$antwoord[7]\";\n");
fputs ($file, "\$antwoord[8] = \"$antwoord[8]\";\n");
fputs ($file, "\$antwoord[9] = \"$antwoord[9]\";\n\n");
if ($stem == $antwoord[0]) { $plusone = $votes[0] + 1; fputs ($file, "\$votes[0] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[0] = \"$votes[0]\";\n"); }
if ($stem == $antwoord[1]) { $plusone = $votes[1] + 1; fputs ($file, "\$votes[1] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[1] = \"$votes[1]\";\n"); }
if ($stem == $antwoord[2]) { $plusone = $votes[2] + 1; fputs ($file, "\$votes[2] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[2] = \"$votes[2]\";\n"); }
if ($stem == $antwoord[3]) { $plusone = $votes[3] + 1; fputs ($file, "\$votes[3] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[3] = \"$votes[3]\";\n"); }
if ($stem == $antwoord[4]) { $plusone = $votes[4] + 1; fputs ($file, "\$votes[4] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[4] = \"$votes[4]\";\n"); }
if ($stem == $antwoord[5]) { $plusone = $votes[5] + 1; fputs ($file, "\$votes[5] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[5] = \"$votes[5]\";\n"); }
if ($stem == $antwoord[6]) { $plusone = $votes[6] + 1; fputs ($file, "\$votes[6] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[6] = \"$votes[6]\";\n"); }
if ($stem == $antwoord[7]) { $plusone = $votes[7] + 1; fputs ($file, "\$votes[7] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[7] = \"$votes[7]\";\n"); }
if ($stem == $antwoord[8]) { $plusone = $votes[8] + 1; fputs ($file, "\$votes[8] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[8] = \"$votes[8]\";\n"); }
if ($stem == $antwoord[9]) { $plusone = $votes[9] + 1; fputs ($file, "\$votes[9] = \"$plusone\";\n"); } else { fputs ($file, "\$votes[9] = \"$votes[9]\";\n"); }
$plusone = $totaal + 1;
fputs ($file, "\$totaal = \"$plusone\";\n");
fputs ($file, "\$vraag = \"$vraag\";\n");
fputs ($file, "?>");
fclose ($file);
echo "<meta http-equiv=refresh content=\"0; URL=$PHP_SELF";
if ($QUERY_STRING) { echo "?$QUERY_STRING\">"; } else { echo "\">"; }
} }
if ($vraag == "") { echo "<font face=verdana size=2><b>Er is geen poll open"; }
else {
$ip = fopen("ip.php", "r");
$contents = fread($ip, filesize("ip.php"));
$uip = $REMOTE_ADDR;
if (eregi("$uip", $contents)) {
echo " <font face=verdana size=2><b>$vraag</b> <font size=1>$totaal ";
if ($totaal == "1") { echo "stem"; } else { echo "stemmen"; }
echo " uitgebracht</font>\n\n";
echo "<table cellpadding=0 cellspacing=0 border=0>\n";
echo " <tr>\n";
echo " <td>\n";
for ($i = 0; $i < count($antwoord); $i++) {
if ($antwoord[$i] == "") { echo ""; } else {
echo " <font face=verdana size=1><b>$antwoord[$i]</b><br></font>\n";
} }
echo " </td>\n";
echo " <td valign=top>\n\n";
echo " <table cellpadding=0 cellspacing=0 border=0>\n";
for ($i = 0; $i < count($votes); $i++) {
if ($votes[$i] == "") { echo ""; } else {
echo " <tr>\n";
echo " <td align=right>\n";
echo " <font face=verdana size=1>";
echo (round(($votes[$i] / $totaal) * 100, 1));
echo "%</font>\n";
echo " </td>\n";
echo " <td>\n";
echo " <img style=\"border: 1 solid #000000\" src=balk.gif height=7 width=";
echo (round(($votes[$i] / $totaal) * 100, 1));
echo "><font face=verdana size=1> $votes[$i] ";
if ($votes[$i] == "1") { echo "stem"; } else { echo "stemmen"; }
echo "<br></font>\n";
echo " </td>\n";
echo " </tr>\n";
} }
echo " </table>\n\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n\n";
} else {
echo " <font face=verdana size=2><b>$vraag</b><br>\n\n";
echo "<table cellpadding=0 cellspacing=0 border=0>\n";
echo " <form name=form method=post><font face=verdana size=1>\n";
for ($i = 0; $i < count($antwoord); $i++) {
if ($antwoord[$i] == "") { echo ""; } else {
echo " <tr>\n";
echo " <td>\n";
echo " <input type=checkbox name=stem value=\"$antwoord[$i]\" id=\"$antwoord[$i]\">\n";
echo " </td>\n";
echo " <td>";
echo "<font size=1><label for=\"$antwoord[$i]\">$antwoord[$i]</label></font>";
echo "</td>\n";
echo " </tr>\n";
} }
echo "</table>\n\n";
echo "<input style=\"font-face: verdana; font-size: 9px\" type=submit value=\" Stem! \">\n";
echo "</form>\n\n";
} }
?>
Niemand ? :(