Guest_imported
New member
- Jan 1, 1970
- 0
Hi.
Can someone tell me, what I'm doing wrong with this *@#$ voting script?
There are three items, you can vote for.
The script should read the data in "Umfrage.txt" line by line into $Vote1, $Vote2, $Vote3, and increase the Item the User has voted for by 1. Than it should rewrite the new data line by line to "Umfrage.txt". But theres something wrong with this writing routine, because always, when I open "Umfrage.txt" there is only s*** in it.
Heres the Script:
<script language="PHP">
$dateiname = "Umfrage.txt";
$Vote1 = 0;
$Vote2 = 0;
$Vote3 = 0;
if(file_exists($dateiname))
{
$datei = fopen($dateiname, "r"
;
if ($datei)
{
$Vote1 = fgets($datei, 255);
$Vote2 = fgets($datei, 255);
$Vote3 = fgets($datei, 255);
fclose($datei);
}
}
if ($id = 1)
{
$Vote1 = $Vote1 + 1;
}
elseif ($id = 2)
{
$Vote2 = $Vote2 + 1;
}
elseif ($id = 3)
{
$Vote3 = $Vote3 + 1;
}
$datei = fopen($dateiname, "w"
;
if ($datei)
{
fputs($datei, "$Vote1\n$Vote2\n$Vote3\n"
;
fclose($datei);
}
echo "$Vote1 $Vote2 $Vote3";
echo "<div Align='Center'>Ihre Abstimmung wurde erfolgreich übermittelt.<br><a href='javascript:history.back()'>Zurück</a></div>";
</script>
P.S.: Sorry for my bad English, but I'm a german, and newbie
Can someone tell me, what I'm doing wrong with this *@#$ voting script?
There are three items, you can vote for.
The script should read the data in "Umfrage.txt" line by line into $Vote1, $Vote2, $Vote3, and increase the Item the User has voted for by 1. Than it should rewrite the new data line by line to "Umfrage.txt". But theres something wrong with this writing routine, because always, when I open "Umfrage.txt" there is only s*** in it.
Heres the Script:
<script language="PHP">
$dateiname = "Umfrage.txt";
$Vote1 = 0;
$Vote2 = 0;
$Vote3 = 0;
if(file_exists($dateiname))
{
$datei = fopen($dateiname, "r"
if ($datei)
{
$Vote1 = fgets($datei, 255);
$Vote2 = fgets($datei, 255);
$Vote3 = fgets($datei, 255);
fclose($datei);
}
}
if ($id = 1)
{
$Vote1 = $Vote1 + 1;
}
elseif ($id = 2)
{
$Vote2 = $Vote2 + 1;
}
elseif ($id = 3)
{
$Vote3 = $Vote3 + 1;
}
$datei = fopen($dateiname, "w"
if ($datei)
{
fputs($datei, "$Vote1\n$Vote2\n$Vote3\n"
fclose($datei);
}
echo "$Vote1 $Vote2 $Vote3";
echo "<div Align='Center'>Ihre Abstimmung wurde erfolgreich übermittelt.<br><a href='javascript:history.back()'>Zurück</a></div>";
</script>
P.S.: Sorry for my bad English, but I'm a german, and newbie