simpele-poll
ob_start();
?>
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<?php
include ('conn.php');
$ip = $_SERVER['REMOTE_ADDR'];
//$sql = "delete from ippoll";
//mysql_query($sql) or die('mislukt; ' . mysql_error());
$sql = "select gemiddelde from ippoll";
$res = mysql_query($sql) or die('mislukt; ' . mysql_error());
$num_rows = mysql_num_rows($res);
$sql2 = "select gemiddelde from ippoll where gemiddelde = '$ip'";
$con = mysql_query($sql2) or die('mislukt; ' . mysql_error());
$controle = mysql_num_rows($con);
if ($controle == 0)
{
print"
<form method='post' action='index.php'>
Wat vind u van deze site: <select name='optie'>
<option value='0'>Poll</option>
<option value='1'>Leuk</option>
<option value='2'>Gaat wel</option>
<option value='3'>Niets aan</option><br>
<input type='submit' value='Stem'>
</form> ";
$controle = "select * from poll";
$controlesql = mysql_query($controle) or die('mislukt; ' . mysql_error());
$fetch = mysql_fetch_array($controlesql);
$controletabel = $fetch ["0"];
if ($fetch < 1)
{
mysql_query("INSERT INTO poll (optie1,optie2,optie3) values ('0','0','0')");
}
else{
if($_SERVER["REQUEST_METHOD"] == "POST")
{
mysql_query("INSERT INTO ippoll (gemiddelde) values ('$ip')");
$optie = $_POST['optie'];
if ($optie == 1)
{
$file = "select * from poll";
$filedel = mysql_query($file) or die('mislukt; ' . mysql_error());
$gegevens = mysql_fetch_array($filedel);
$array1 = $gegevens ["0"];
$array2 = $gegevens ["1"];
$array3 = $gegevens ["2"];
$resultaat = $array1 + 1;
$sql = "delete from poll";
$res = mysql_query($sql) or die('mislukt; ' . mysql_error());
mysql_query("INSERT INTO poll (optie1,optie2,optie3) values ('$resultaat','$array2','$array3')");
$stemmen = $array1 + $array2 + $array3;
$gem1 = round (@($array1 / $stemmen) * 100,1);
$gem2 = round (@($array2 / $stemmen) * 100,1);
$gem3 = round (@($array3 / $stemmen) * 100,1);
print "<span class='poll'><br>$gem1% vind dit een mooie site.<br>";
print "$gem2% vind dit een redelijke site.<br>";
print "$gem3% vind dit geen mooie site.</span>";
}
elseif ($optie == 2)
{
$file = "select * from poll";
$filedel = mysql_query($file) or die('mislukt; ' . mysql_error());
$gegevens = mysql_fetch_array($filedel);
$array1 = $gegevens ["0"];
$array2 = $gegevens ["1"];
$array3 = $gegevens ["2"];
$resultaat = $array2+ 1;
$sql = "delete from poll";
$res = mysql_query($sql) or die('mislukt; ' . mysql_error());
mysql_query("INSERT INTO poll (optie1,optie2,optie3) values ('$array1','$resultaat','$array3')");
if ($array = 1)
$stemmen = $array1 + $array2 + $array3;
$gem1 = round (@($array1 / $stemmen) * 100,1);
$gem2 = round (@($array2 / $stemmen) * 100,1);
$gem3 = round (@($array3 / $stemmen) * 100,1);
print "<span class='poll'><br>$gem1% vind dit een mooie site.<br>";
print "$gem2% vind dit een redelijke site.<br>";
print "$gem3% vind dit geen mooie site.</span>";
}
elseif ($optie == 3)
{
$file = "select * from poll";
$filedel = mysql_query($file) or die('mislukt; ' . mysql_error());
$gegevens = mysql_fetch_array($filedel);
$array1 = $gegevens ["0"];
$array2 = $gegevens ["1"];
$array3 = $gegevens ["2"];
$resultaat = $array3 + 1;
$stemmen = $array1 + $array2 + $array3;
$gem1 = round (@($array1 / $stemmen) * 100,0);
$gem2 = round (@($array2 / $stemmen) * 100,0);
$gem3 = round (@($array3 / $stemmen) * 100,0);
print "<span class='poll'><br>$gem1% vind dit een mooie site.<br>";
print "$gem2% vind dit een redelijke site.<br>";
print "$gem3% vind dit geen mooie site.</span>";
$sql = "delete from poll";
$res = mysql_query($sql) or die('mislukt; ' . mysql_error());
mysql_query("INSERT INTO poll (optie1,optie2,optie3) values ('$array1','$array2','$resultaat')");
}
elseif ($optie == 0)
{
Print "ongeldige keuze";
}
}
else
{
print "maak een keuze";
}
}
}
else
{
print "<span class='poll'><b>U heeft al op deze poll gestemd</b>";
$file = "select * from poll";
$filedel = mysql_query($file) or die('mislukt; ' . mysql_error());
$gegevens = mysql_fetch_array($filedel);
$array1 = $gegevens ["0"];
$array2 = $gegevens ["1"];
$array3 = $gegevens ["2"];
$resultaat = $array3 + 1;
$stemmen = $array1 + $array2 + $array3;
$gem1 = round (@($array1 / $stemmen) * 100,0);
$gem2 = round (@($array2 / $stemmen) * 100,0);
$gem4 = round (@(($array3 + $array2) / $stemmen) * 100,0);
$gem3 = round (@($array3 / $stemmen) * 100,0);
$balk1 = $gem1 * 2;
$balk2= $gem2 * 2;
$balk3= $gem3 * 2;
print "<br>$gem1% Vind dit een mooie site.<br>";
print "<table cellpadding='0' cellspacing='0'><td width='$balk1' bgcolor='black' height='5'></tr></td></table>";
print "$gem2% Vind dit een redelijke site.<br>";
print "<table cellpadding='0' cellspacing='0'><td width='$balk2' bgcolor='black' height='5'></tr></td></table>";
print "$gem3% Vind dit geen mooie site.<br>";
print "<table cellpadding='0' cellspacing='0'><td width='$balk3' bgcolor='black' height='5'></tr></td></table>";
print "<b>Aantal stemmen: $stemmen </b></span>";
}
?>
include ('conn.php');
$ip = $_SERVER['REMOTE_ADDR'];
//$sql = "delete from ippoll";
//mysql_query($sql) or die('mislukt; ' . mysql_error());
$sql = "select gemiddelde from ippoll";
$res = mysql_query($sql) or die('mislukt; ' . mysql_error());
$num_rows = mysql_num_rows($res);
$sql2 = "select gemiddelde from ippoll where gemiddelde = '$ip'";
$con = mysql_query($sql2) or die('mislukt; ' . mysql_error());
$controle = mysql_num_rows($con);
if ($controle == 0)
{
print"
<form method='post' action='index.php'>
Wat vind u van deze site: <select name='optie'>
<option value='0'>Poll</option>
<option value='1'>Leuk</option>
<option value='2'>Gaat wel</option>
<option value='3'>Niets aan</option><br>
<input type='submit' value='Stem'>
</form> ";
$controle = "select * from poll";
$controlesql = mysql_query($controle) or die('mislukt; ' . mysql_error());
$fetch = mysql_fetch_array($controlesql);
$controletabel = $fetch ["0"];
if ($fetch < 1)
{
mysql_query("INSERT INTO poll (optie1,optie2,optie3) values ('0','0','0')");
}
else{
if($_SERVER["REQUEST_METHOD"] == "POST")
{
mysql_query("INSERT INTO ippoll (gemiddelde) values ('$ip')");
$optie = $_POST['optie'];
if ($optie == 1)
{
$file = "select * from poll";
$filedel = mysql_query($file) or die('mislukt; ' . mysql_error());
$gegevens = mysql_fetch_array($filedel);
$array1 = $gegevens ["0"];
$array2 = $gegevens ["1"];
$array3 = $gegevens ["2"];
$resultaat = $array1 + 1;
$sql = "delete from poll";
$res = mysql_query($sql) or die('mislukt; ' . mysql_error());
mysql_query("INSERT INTO poll (optie1,optie2,optie3) values ('$resultaat','$array2','$array3')");
$stemmen = $array1 + $array2 + $array3;
$gem1 = round (@($array1 / $stemmen) * 100,1);
$gem2 = round (@($array2 / $stemmen) * 100,1);
$gem3 = round (@($array3 / $stemmen) * 100,1);
print "<span class='poll'><br>$gem1% vind dit een mooie site.<br>";
print "$gem2% vind dit een redelijke site.<br>";
print "$gem3% vind dit geen mooie site.</span>";
}
elseif ($optie == 2)
{
$file = "select * from poll";
$filedel = mysql_query($file) or die('mislukt; ' . mysql_error());
$gegevens = mysql_fetch_array($filedel);
$array1 = $gegevens ["0"];
$array2 = $gegevens ["1"];
$array3 = $gegevens ["2"];
$resultaat = $array2+ 1;
$sql = "delete from poll";
$res = mysql_query($sql) or die('mislukt; ' . mysql_error());
mysql_query("INSERT INTO poll (optie1,optie2,optie3) values ('$array1','$resultaat','$array3')");
if ($array = 1)
$stemmen = $array1 + $array2 + $array3;
$gem1 = round (@($array1 / $stemmen) * 100,1);
$gem2 = round (@($array2 / $stemmen) * 100,1);
$gem3 = round (@($array3 / $stemmen) * 100,1);
print "<span class='poll'><br>$gem1% vind dit een mooie site.<br>";
print "$gem2% vind dit een redelijke site.<br>";
print "$gem3% vind dit geen mooie site.</span>";
}
elseif ($optie == 3)
{
$file = "select * from poll";
$filedel = mysql_query($file) or die('mislukt; ' . mysql_error());
$gegevens = mysql_fetch_array($filedel);
$array1 = $gegevens ["0"];
$array2 = $gegevens ["1"];
$array3 = $gegevens ["2"];
$resultaat = $array3 + 1;
$stemmen = $array1 + $array2 + $array3;
$gem1 = round (@($array1 / $stemmen) * 100,0);
$gem2 = round (@($array2 / $stemmen) * 100,0);
$gem3 = round (@($array3 / $stemmen) * 100,0);
print "<span class='poll'><br>$gem1% vind dit een mooie site.<br>";
print "$gem2% vind dit een redelijke site.<br>";
print "$gem3% vind dit geen mooie site.</span>";
$sql = "delete from poll";
$res = mysql_query($sql) or die('mislukt; ' . mysql_error());
mysql_query("INSERT INTO poll (optie1,optie2,optie3) values ('$array1','$array2','$resultaat')");
}
elseif ($optie == 0)
{
Print "ongeldige keuze";
}
}
else
{
print "maak een keuze";
}
}
}
else
{
print "<span class='poll'><b>U heeft al op deze poll gestemd</b>";
$file = "select * from poll";
$filedel = mysql_query($file) or die('mislukt; ' . mysql_error());
$gegevens = mysql_fetch_array($filedel);
$array1 = $gegevens ["0"];
$array2 = $gegevens ["1"];
$array3 = $gegevens ["2"];
$resultaat = $array3 + 1;
$stemmen = $array1 + $array2 + $array3;
$gem1 = round (@($array1 / $stemmen) * 100,0);
$gem2 = round (@($array2 / $stemmen) * 100,0);
$gem4 = round (@(($array3 + $array2) / $stemmen) * 100,0);
$gem3 = round (@($array3 / $stemmen) * 100,0);
$balk1 = $gem1 * 2;
$balk2= $gem2 * 2;
$balk3= $gem3 * 2;
print "<br>$gem1% Vind dit een mooie site.<br>";
print "<table cellpadding='0' cellspacing='0'><td width='$balk1' bgcolor='black' height='5'></tr></td></table>";
print "$gem2% Vind dit een redelijke site.<br>";
print "<table cellpadding='0' cellspacing='0'><td width='$balk2' bgcolor='black' height='5'></tr></td></table>";
print "$gem3% Vind dit geen mooie site.<br>";
print "<table cellpadding='0' cellspacing='0'><td width='$balk3' bgcolor='black' height='5'></tr></td></table>";
print "<b>Aantal stemmen: $stemmen </b></span>";
}
?>