Hoi,
Ik ben bezig met een poll, alles werkt maar zodra ik de CSS link enzo aan toevoeg krijg ik deze error:
Warning: Cannot modify header information - headers already sent by (output started at /home/mzoomers/public_html/poll/admin.php:6) in /home/mzoomers/public_html/poll/admin.php on line 38
Ik weet dat het door de cookie komt, maar ik zou niet weten hoe ik die anders kan zetten. Iemand die mij kan helpen?
poll.php
admin.php
Ik ben bezig met een poll, alles werkt maar zodra ik de CSS link enzo aan toevoeg krijg ik deze error:
Warning: Cannot modify header information - headers already sent by (output started at /home/mzoomers/public_html/poll/admin.php:6) in /home/mzoomers/public_html/poll/admin.php on line 38
Ik weet dat het door de cookie komt, maar ik zou niet weten hoe ik die anders kan zetten. Iemand die mij kan helpen?
poll.php
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
| <? require("config.php"); echo "<link href=\"css\style.css\" rel=\"stylesheet\" type=\"text/css\"> <body class=\"maintable\">"; if($_GET[poll] == "stem") { $update = "UPDATE poll SET votes = votes + 1, $_POST[keuze] = $_POST[keuze] + 1 WHERE id = $_GET[id]"; $query = mysql_query($update); $cookie = $HTTP_COOKIE_VARS['poll']; setcookie("poll", $cookie.'-'.$_GET[id], time()+3600*24*7*52); header("location: poll.php?poll=uitslagen"); } $select = "SELECT * FROM poll ORDER BY id DESC LIMIT 1"; $query = mysql_query($select); while ($row = mysql_fetch_object($query)) { echo "<form method=\"post\" action=\"poll.php?poll=stem&id=$row->id\">"; echo "<b>$row->vraag</b><br>"; $cookie = $HTTP_COOKIE_VARS['poll']; $data = explode('-', $cookie); $gestemd = ""; for ($i = 0; $i < count($data); $i++) { if($data[$i] == $row->id) { $gestemd = "ja"; } } if(($_GET[poll] == uitslagen) OR ("$gestemd" == "ja")) { @$procent = 100 / $row->votes; for($i=1; $i <= $row->aantal; $i++) { $antwoord = "antwoord$i"; $keuze = "keuze$i"; $aantal = $row->$keuze; @$breedte = $row->$keuze * $procent; @$breedte = round($breedte,0); echo $row->$antwoord." ($breedte%)<br>"; echo "[img]\"poll.gif\"[/img]<br> \n"; } } elseif($gestemd == "") { for($i=1; $i <= $row->aantal; $i++) { $antwoord = "antwoord$i"; echo "<input type=\"radio\" name=\"keuze\" value=\"keuze$i\">".$row->$antwoord."<br> \n"; } echo "<input name=\"verzend\" type=\"submit\" value=\"Stem!\"><br>"; echo "<a href=\"poll.php?poll=uitslagen\">uitslagen</a>"; echo "</form>"; } } ?> </body> |
admin.php
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
| <? require("config.php"); echo "<link href=\"css\style.css\" rel=\"stylesheet\" type=\"text/css\"> <body class=\"maintable\">"; if ($_GET[actie] == "") { echo "Poll admin<p>"; echo "<a href=admin.php?actie=nieuw>Plaats een nieuwe poll.</a><br><hr>"; $select = "SELECT * FROM poll ORDER BY id ASC"; $res = mysql_query($select) or die(mysql_error()); echo "<table>"; while($row = mysql_fetch_object($res)) { echo "<tr>"; echo "<td width=250>$row->vraag<br></td>"; echo "<td><a href=\"?actie=delete&id=$row->id\">Delete</a><br></td>"; echo "<td><a href=\"?actie=edit&id=$row->id\">Verander</a><br></td>"; echo "</tr>"; } echo "</table>"; } elseif ($_GET[actie] == "nieuw") { if ($_POST[submit]) { $query = "INSERT INTO poll (vraag, aantal, antwoord1, antwoord2, antwoord3, antwoord4, antwoord5) VALUES ('$_POST[vraag]', '$_POST[aantal]', '$_POST[antwoord1]', '$_POST[antwoord2]', '$_POST[antwoord3]', '$_POST[antwoord4]', '$_POST[antwoord5]')"; mysql_query($query) or die (mysql_error()); header("location: admin.php"); } else { echo "Nieuwe poll<p>"; ?> <form method="post" action="admin.php?actie=nieuw"> Vraag <input name="vraag" type="text"><br> Aantal keuzes <select name="aantal" id="aantal"> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select><br> Antwoord 1 <input name="antwoord1" type="text"><br> Antwoord 2 <input name="antwoord2" type="text"><br> Antwoord 3 <input name="antwoord3" type="text"><br> Antwoord 4 <input name="antwoord4" type="text"><br> Antwoord 5 <input name="antwoord5" type="text"><br> <input name="submit" type="submit" id="submit" value="Maak"> </form> <? } } elseif ($_GET[actie] == "edit") { if ($_POST[submit]) { $query = "UPDATE poll SET vraagkort = '$_POST[vraagkort]', vraag = '$_POST[vraag]', aantal = '$_POST[aantal]', antwoord1 = '$_POST[antwoord1]', antwoord2 = '$_POST[antwoord2]', antwoord3 = '$_POST[antwoord3]', antwoord4 = '$_POST[antwoord4]', antwoord5 = '$_POST[antwoord5]' WHERE id = '$_GET[id]'"; mysql_query($query) or die (mysql_error()); header("location: admin.php"); } else { echo "Bewerk poll<p>"; $select = "SELECT * FROM poll WHERE id = '$_GET[id]' ORDER BY id ASC"; $res = mysql_query($select) or die(mysql_error()); while($row = mysql_fetch_object($res)) { ?> <form method="post" action="admin.php?actie=edit&id=<?=$_GET[id] ?>"> Vraag <input name="vraag" type="text" value="<?=$row->vraag ?>"><br> Aantal keuzes (opnieuw kiezen) <select name="aantal" id="aantal"> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select><br> Antwoord 1 <input name="antwoord1" type="text" value="<?=$row->antwoord1 ?>"><br> Antwoord 2 <input name="antwoord2" type="text" value="<?=$row->antwoord2 ?>"><br> Antwoord 3 <input name="antwoord3" type="text" value="<?=$row->antwoord3 ?>"><br> Antwoord 4 <input name="antwoord4" type="text" value="<?=$row->antwoord4 ?>"><br> Antwoord 5 <input name="antwoord5" type="text" value="<?=$row->antwoord5 ?>"><br> <input name="submit" type="submit" id="submit" value="Maak"> </form> <? } } } elseif ($_GET[actie] == "delete") { $query = "DELETE FROM poll WHERE id = '$_GET[id]'"; mysql_query($query) or die (mysql_error()); header("location: admin.php"); } ?> </body> |