Hallo zusammen.
Ich hät ein Problem mit meinem Umfragenscript welches ich aus dem Internet habe. Ich weiß nicht wo das Problem liegt.
So gehts ja erst, aber wenn man dann z.b. "Super" auswählt und auf abstimmen klickt, kommt das:
Warning: fopen(daten/stimmen.txt) [function.fopen]: failed to open stream: No such file or directory in /home/Maggus/public_html/polls/umfrage.php on line 50
Warning: filesize() [function.filesize]: stat failed for daten/stimmen.txt in /home/Maggus/public_html/polls/umfrage.php on line 54
Warning: fread(): supplied argument is not a valid stream resource in /home/Maggus/public_html/polls/umfrage.php on line 54
Warning: rewind(): supplied argument is not a valid stream resource in /home/Maggus/public_html/polls/umfrage.php on line 68
Warning: fputs(): supplied argument is not a valid stream resource in /home/Maggus/public_html/polls/umfrage.php on line 69
Warning: fclose(): supplied argument is not a valid stream resource in /home/Maggus/public_html/polls/umfrage.php on line 70
Ihr könnt das auch selbst anschauen auf:
www.maggus.byto.de/polls/umfrage.php
Danke schonmal
MFG Maggus
Mod-Edit: Code-Tags verwenden! (Prophet)
Ich hät ein Problem mit meinem Umfragenscript welches ich aus dem Internet habe. Ich weiß nicht wo das Problem liegt.
PHP:
<?php
if (isset($_POST["ergebnis"])) {
// Aktuelle Sperre 1 Minute
// 30 Tage Sperre time()+60*60*24*30
setcookie("abgestimmt","ja",time()+60);
}
$thema = "Atomic-Umfrage 2004";
$auswahl = array("Super","Sehr Gut","Gut","Naja","Schlecht");
$anzahl = count($auswahl);
?>
<html>
<head>
<title>Atomic-Umfrage</title>
<link rel='stylesheet' type='text/css' href='css/umfrage.css'>
</head>
<body>
<img src='bild/umfragelogo.gif' width='506' height='62'><br>
<h3><?php echo $thema ?></h3>
<form method='post' action='<?php echo $PHP_SELF; ?>'>
<p>
<?php
foreach ($auswahl as $key=>$eintrag) {
echo "<input type='radio' name='ergebnis' value='$key'> $eintrag<br>\n";
}
?>
</p>
<?php
if (empty($_COOKIE["abgestimmt"]) && !isset($_POST["ergebnis"])) {
// Submit nur zeigen, wenn Formular noch nicht abgeschickt wurde
echo "<input type='submit' value='Daten senden'>";
} else {
echo "<p>Danke für die Übermittlung der Daten!</p>\n";
// Formular abgeschickt? Aber bisher noch nicht abgestimmt?
if (empty($_COOKIE["abgestimmt"]) && isset($_POST["ergebnis"])) {
// Dateiname in Variable speichern
$datei="daten/stimmen.txt";
// Datei vorhanden?
if (file_exists($datei)) {
$fp=fopen($datei,"r+");
} else {
$fp=fopen($datei,"w");
}
// Datei einlesen
$stimmen=fread($fp,filesize($datei));
// String aus Datei in Array zerlegen
$stimmen=explode(",",$stimmen);
// Der gewählte Punkt wird um 1 erhöht!
$stimmen[$_POST["ergebnis"]]++;
// Stimmen in einem String zusammensetzen
for ($i=0;$i<$anzahl;$i++) {
$total .= $stimmen[$i] .",";
}
// Neuen String in Datei schreiben
rewind($fp);
fputs($fp,$total);
fclose($fp);
}
}
?>
</form>
<p>
[ <a href='ergebnis.php' target='_blank'>Umfrageergebnisse betrachten</a> ]
</p>
</body>
</html>
So gehts ja erst, aber wenn man dann z.b. "Super" auswählt und auf abstimmen klickt, kommt das:
Warning: fopen(daten/stimmen.txt) [function.fopen]: failed to open stream: No such file or directory in /home/Maggus/public_html/polls/umfrage.php on line 50
Warning: filesize() [function.filesize]: stat failed for daten/stimmen.txt in /home/Maggus/public_html/polls/umfrage.php on line 54
Warning: fread(): supplied argument is not a valid stream resource in /home/Maggus/public_html/polls/umfrage.php on line 54
Warning: rewind(): supplied argument is not a valid stream resource in /home/Maggus/public_html/polls/umfrage.php on line 68
Warning: fputs(): supplied argument is not a valid stream resource in /home/Maggus/public_html/polls/umfrage.php on line 69
Warning: fclose(): supplied argument is not a valid stream resource in /home/Maggus/public_html/polls/umfrage.php on line 70
Ihr könnt das auch selbst anschauen auf:
www.maggus.byto.de/polls/umfrage.php
Danke schonmal
MFG Maggus
Mod-Edit: Code-Tags verwenden! (Prophet)
Zuletzt bearbeitet von einem Moderator: