det blev fel. så här ska koden se ut.
<?php
/*
///////// PHPOLLS v2.1
/////////
Copyright 2000, Mathias Daval / PHPVault (http://www.phpvault.com)
//////////////////////////////////////////////////////////////////////////
Ce script est un freeware. Vous pouvez l'utiliser et le modifier librement, mais vous devez laisser
le copyright. Merci de me faire savoir si vous trouvez ce script utile. (webmaster@phpvault.com)
PHPolls permet de créer des sondages avec un affichage graphique des résultats, sans avoir besoin
de base de données.
/////////////////////////////////////////////////////////////////////////
This script is a freeware. You can use it and modify it freely as long as you leave the copyright.
Please tell me if you find this script useful
(webmaster@phpvault.com)
PHPolls allows the webmaster to create online polls, with graphical display of the results, with no
need of database.
/////////////////////////////////////////////////////////////////////////
Installation:
1. Copy this file in the directory of your choice (must be accessible to reading and writing) /
Copier ce fichier dans le répertoire de votre choix, (accessible en lecture et en écriture)
2. Create a blank file called votes.dat / Créer un fichier vierge appelé votes.dat.
3. Create a file called data.dat which contains the choices of your poll (1 line per choice) /
Créer un fichier appelé data.dat qui contient les choix de votre sondage (1 ligne par choix)
4. Choose an image for the graphical display of the results / Choisissez une image pour l'affichage
des résultats.
5. Insert the poll wherever you want in a PHP page with the line / Insérer le sondage à l'endroit
souhaité dans une page en PHP avec la ligne :
<? require("index.php"); ?>
/////////////////////////////////////////////////////////////////////// */
/* Chemin d'accès à data.dat / Path to data.dat */
$data="data.dat";
/* Chemin d'accès à votes.dat / Path to votes.dat */
$votes="votes.dat";
/* Chemin d'accès au fichier image / Path to the image file */
$path_img="gfx/red.gif";
/* Nom de votre sondage / Name of your poll */
$poll_name="Vem skulle du mest av allt vilja vara?";
///////////////////////////////
// NOTHING TO CHANGE BELOW //
///////////////////////////////
$dataf=file("data.dat");
if ($go !=1) {
/* Impression des choix */
echo "<span class=normal><b>$poll_name</b></span><br>\n";
echo "<form method=post>";
for ($i=0; $i<=count($dataf)-1; $i++) {
echo "<input type=radio name=\"vote\" value=\"$i\"> $dataf[$i]<br>\n";
}
echo "<input type=hidden name=go value=1>";
echo "<p><center><input type=submit value=rösta class=normal>";
echo "</form>";
echo "<span class=normal><b><a href='index.php3?result=1&go=1'>resultat</a></b></span>";
}
else {
$file_votes=fopen($votes, "r");
$line_votes=fgets($file_votes, 255);
$single_vote=explode("|", $line_votes);
fclose($file_votes);
if ($result!=1) {
/* Log du vote */
$file_votes=file($votes, "r");
if ($REMOTE_ADDR == $file_votes[1]) {
echo "<span class=normal><b><font color=red>du har redan röstat!</font></b></span>";
exit;
}
$ficdest=fopen($votes, "w");
for ($i=0; $i<=count($dataf)-1; $i++) {
if ($i == $vote) {
$single_vote[$i]+=1;
}
fputs($ficdest, "$single_vote[$i]|");
}
fclose($ficdest);
$ficdest=fopen($votes, "a");
fputs($ficdest, "\n$REMOTE_ADDR");
fclose($ficdest);
$result=1;
}
if ($result==1) {
/* Affichage des résultats */
echo "<table cellpadding=10>";
echo "<tr><td align=left><span class=normal>";
echo "<b>Val</b></span>";
echo "</td><td align=left><span class=normal>";
echo "<b>%</b></span></td>";
echo "<td align=left><span class=normal>";
echo "<b>Röster</b></span></td></tr>";
for ($i=0; $i<=count($dataf)-1; $i++) {
$tot_votes+=$single_vote[$i];
}
for ($i=0; $i<=count($dataf)-1; $i++) {
$stat[$i]=$single_vote[$i]/$tot_votes*100;
echo "<tr><td><span class=normal>";
echo "$dataf[$i]</font></td><td align=left><span class=normal>";
echo "<img src=\"$path_img\" height=10 width=$stat[$i] align=middle> ";
printf("%.1f", "$stat[$i]");
echo "%</span></td><td align=left><span class=normal>";
echo "$single_vote[$i]</span>";
echo "</td></tr>";
}
echo "</table>";
echo "<span class=normal><b>Totalt: $tot_votes röster</b></span>";
}
}
?>
------------------
/lennon