login  Naam:   Wachtwoord: 
Registreer je!
 Forum

poll stemt automatish

Offline baracus - 02/01/2005 12:14 (laatste wijziging 02/01/2005 12:15)
Avatar van baracusNieuw lid hi,als je op mijn site gaat http://celeb.clansoil.com klik je op mini poll, vote je, en als je de results ziet,klik je op refresh, dan zul je zien dat je die naam waarop je gevote hebt, nog een stem heeft gekregen. hoe los ik dit op?

  1. <?php
  2. // Deze moet je zeker invullen !!:
  3.  
  4. $RESULT_FILE_NAME = "poll_data.txt";
  5. // schrijf hier het bestand naar waar hij schrijft
  6. $QUESTION = "Who's your favorite celebrity";
  7. // Schrijf hier de vraag van je poll.
  8. $ANSWER = array("avril lavigne", "britney spears", "brooke burke" ,"carmen electra" , "christina aguilera" , "heidi klum" , "jessica simpson" , "pamela anderson" , "victoria silvstedt");
  9. // zet hier alle antwoorden
  10.  
  11. $IMG_DIR_URL = "./vote";
  12. // map waar afbeelding voor poll wordt opgeslaan bij deze in de map vote dus
  13.  
  14. $REVOTE_TIME = 3600;
  15. // Tijd tussen herstemmen
  16.  
  17. // Begin Poll
  18. /******************************************************************************/
  19.  
  20. if (! $vote && ! $result) {
  21. echo "<FORM METHOD=\"POST\">\n";
  22. echo "<TABLE WIDTH=100% BORDER=0><TR><TD><TABLE WIDTH=\"100%\" BORDER=0>\n";
  23. echo "<TR><TH style='font-family: Arial; font-size: 10 pt;'><center>$QUESTION</center></TH></TR>\n";
  24. echo "</TABLE>";
  25. while (list($key, $val) = each($ANSWER)) {
  26. echo "<TR><TD><TABLE WIDTH=\"30%\" BORDER=0 cellspacing=0>\n";
  27. echo "<TR><TD align=\"right\" width=20%><INPUT TYPE=\"radio\" NAME=\"answer\" VALUE=\"$key\" style='font-family: Arial; font-size: 10 pt;'></TD><td width=20% style='font-family: Arial; font-size: 10 pt;'>$val</td></TR>\n";
  28. echo "</table>";
  29. }
  30. echo "<TR><TD align=\"center\"><INPUT TYPE=\"Submit\" NAME=\"vote\" VALUE=\" Vote \" style='font-family: Arial; font-size: 10 pt; font-weight: bold; text-align: center; border-style: solid; border-width: 1'></TD></TR>\n";
  31. echo "<TR><TD align=\"center\"><INPUT TYPE=\"Submit\" NAME=\"result\" VALUE=\" See Result \" style='font-family: Arial; font-size: 10 pt; font-weight: bold; text-align: center; border-style: solid; border-width: 1'></TD></TR>\n";
  32. echo "</TABLE></TD></TR></TABLE></FORM>";
  33. } else {
  34.  
  35. $file_array = file($RESULT_FILE_NAME); // or error("Can not open \$RESULT_FILE_NAME");
  36.  
  37. // het opslaan van de resultaten
  38. if ($answer < count($ANSWER) && $vote) {
  39. if (count($file_array) < count($ANSWER)) {
  40. $file_array = array("0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n");
  41. }
  42. $old_answer = $file_array[$answer];
  43. $old_answer = preg_replace("/\n\r*/", "", $old_answer);
  44. $file_array[$answer] = ($old_answer + 1)."\n";
  45.  
  46. $file = join('', $file_array);
  47. $fp = fopen("$RESULT_FILE_NAME", "w"); //or error("Can not write \$RESULT_FILE_NAME");
  48. flock($fp, 1);
  49. fputs($fp, $file);
  50. flock($fp, 3);
  51. fclose($fp);
  52. echo "";
  53. }
  54.  
  55. // weergeven van de resultaten
  56. while (list($key, $val) = each($file_array)) {
  57. $total += $val;
  58. }
  59.  
  60. echo "<center><h5>Poll results :</h5></center>";
  61. echo "<TABLE CELLSPACING=2 CELLPADDING=2 BORDER=0 align=left>";
  62. echo "<tr><th width='30%' style='font-family: Arial; font-size: 10 pt;'>Answer</th><th width='30%' style='font-family: Arial; font-size: 10 pt;'>Percentage</th><th style='font-family: Arial; font-size: 10 pt;' width='40%'> </th></tr>";
  63.  
  64. while (list($key, $val) = each($ANSWER)) {
  65. $percent = $file_array[$key] * 100 / $total;
  66. $percent_int = floor($percent + (0.5));
  67. $percent_float = number_format($percent, 1);
  68. $tp += $percent_float;
  69. echo "<tr><td style='font-family: Arial; font-size: 10 pt;'> $ANSWER[$key] </td><td style='font-family: Arial; font-size: 10 pt;'><img height=9 src=\"$IMG_DIR_URL/vote_left.gif\"><img height=9 width=\"$percent_int\" src=\"$IMG_DIR_URL/vote_middle.gif\"><img height=9 src=\"$IMG_DIR_URL/vote_right.gif\"><br> $percent_float % ($file_array[$key])</td><td style='font-family: Arial; font-size: 10 pt;' width='%'> </td></tr>";
  70. }
  71.  
  72. echo "</TABLE><br>";
  73. }
  74. if (isset($HTTP_COOKIE_VARS["votingstep"])) {
  75.  
  76. setcookie("votingstep","1",time()+1);}
  77.  
  78. ?>

0 antwoorden

Gesponsorde links
Er zijn nog geen reacties op dit bericht.
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.195s