HTML interesse |
|
Zit met volgend scriptje, poll wordt goed uitgelezen, ik kan stemmen, stemmen worden opgeslaan in de database maar als'k dan opnieuw poll klik kan ik terug stemmen => cookie wordt niet opgeslagen.
Ben nog niet lang bezig met php en dit is een iets aangepast script vanop een andere site
<?php
include("cfg.inc.php");
$query = mysql_query("SELECT * FROM polls ORDER BY id DESC LIMIT 0,1") or die(mysql_error());
$pollid = mysql_result($query,0,"id");
$vraag = mysql_result($query,0,"vraag");
$poll_cookie = "kljdoorslaar" . $pollid;
if(isset($_COOKIE["poll"])) {
// antwoorden
echo "<html><head><link href='../includes/style.css' type='text/css' rel='stylesheet'><script type='text/JavaScript'> function delAdds() { document.all.tags('div')[0].outerHTML = ''; </script></head><body onload='delAdds()'> ";
$query = mysql_query("SELECT * FROM poll_opties WHERE pollid='" . $pollid . "' ORDER BY id ASC") or die(mysql_error());
$totaal = 0;
while ($var = mysql_fetch_object($query)) {
$totaal = $totaal + $var->votes;
}
echo "<table width='600' align='center' cellspacing='0'><tr><td width='300'><b> " . $vraag . "</b></td><td width='250'> " . $totaal . " stemmen</td><td width='50'> </td></tr>";
$query = mysql_query("SELECT * FROM poll_opties WHERE pollid='" . $pollid . "' ORDER BY id ASC") or die(mysql_error());
while ($var = mysql_fetch_object($query)) {
$percentage = (integer)(($var->votes / $totaal) * 100);
echo "<tr><td align='left'>" . $var->optie . " </td>";
echo "<td align='left'><img src='polllinks.jpg'><img src='poll.jpg' width='" . $percentage * 2 . "' height='15'><img src='pollrechts.jpg'> (" . $var->votes . " stemmen) </td>";
echo "<td align='right'> " . $percentage . " % </td></tr>";
}
echo "</table>";
} else {
// stemmen?
setcookie ("poll", "stem", time()+5184000);
echo "<html><head><link href='../includes/style.css' type='text/css' rel='stylesheet'><script type='text/JavaScript'> function delAdds() { document.all.tags('div')[0].outerHTML = ''; </script></head><body onload='delAdds()'> ";
echo "<form action=\"poll_stemmen.php\" method=\"POST\">";
echo "<table width='600' align='center' cellspacing='0'>";
echo "<tr><td colspan=\"2\"><b>" . $vraag . "</b></td></tr>";
$query = mysql_query("SELECT * FROM poll_opties WHERE pollid='" . $pollid . "' ORDER BY id ASC") or die(mysql_error());
while ($var = mysql_fetch_object($query)) {
echo "<tr><td><input class=\"form\" type=\"radio\" name=\"vote\" value=\"" . $var->id . "\"> " . $var->optie . "</td></tr>\n";
}
echo "<tr><td vAlign=right><input class=\"form\" type=\"submit\" value=\"Stemmen!\" name=\"stemmen\"></form></td></tr></table>\n\n";
}
?>
<noframes>
<?php include("cfg.inc.php"); $poll_cookie = "kljdoorslaar" . $pollid; if(isset($_COOKIE["poll"])) { // antwoorden echo "<html><head><link href='../includes/style.css' type='text/css' rel='stylesheet'><script type='text/JavaScript'> function delAdds() { document.all.tags('div')[0].outerHTML = ''; </script></head><body onload='delAdds()'> "; $totaal = 0; $totaal = $totaal + $var->votes; } echo "<table width='600' align='center' cellspacing='0'><tr><td width='300'><b> " . $vraag . "</b></td><td width='250'> " . $totaal . " stemmen</td><td width='50'> </td></tr>"; $percentage = (integer)(($var->votes / $totaal) * 100); echo "<tr><td align='left'>" . $var->optie . " </td>"; echo "<td align='left'><img src='polllinks.jpg'><img src='poll.jpg' width='" . $percentage * 2 . "' height='15'><img src='pollrechts.jpg'> (" . $var->votes . " stemmen) </td>"; echo "<td align='right'> " . $percentage . " % </td></tr>"; } } else { // stemmen? echo "<html><head><link href='../includes/style.css' type='text/css' rel='stylesheet'><script type='text/JavaScript'> function delAdds() { document.all.tags('div')[0].outerHTML = ''; </script></head><body onload='delAdds()'> "; echo "<form action=\"poll_stemmen.php\" method=\"POST\">"; echo "<table width='600' align='center' cellspacing='0'>"; echo "<tr><td colspan=\"2\"><b>" . $vraag . "</b></td></tr>"; echo "<tr><td><input class=\"form\" type=\"radio\" name=\"vote\" value=\"" . $var->id . "\"> " . $var->optie . "</td></tr>\n"; } echo "<tr><td vAlign=right><input class=\"form\" type=\"submit\" value=\"Stemmen!\" name=\"stemmen\"></form></td></tr></table>\n\n"; } ?> <noframes>
|