Ich brauche ein einfaches Umfragesystem, welches zusätzlich zu der Abstimmung ein Feld für den Namen beinhaltet. Das Ergebnis der Umfrage sollte dann in eine Textdatei gespeichert werden.
Soweit bin ich bisher:
inhalt.html
Das war nur das Formular, welches das Ergebnis an vote.php sendet:
Nun bekomme ich den Fehler nach dem Absenden des Formulars:
Parse error: syntax error, unexpected $end in /vote.php on line 112
[MOD: Tags geändert]
Soweit bin ich bisher:
inhalt.html
PHP-Code:
<html>
<body>
<form action="vote.php" method="post">
<p><span class="Stil3">Dein Name:
<input type="text" name="name" size="24">
<br>
<br>
<fieldset>
<legend>Auswahl:</legend>
<fieldset>
<span class="Stil3">
<label>
<input type="checkbox" name="Termin" value="1" />
Termin 1</label>
<br>
<label>
<input type="checkbox" name="Termin" value="2" />
Termin 2</label>
<br>
</span><font size="1" face="Verdana"><br>
<input type=submit>
<input type=reset>
</body>
</html>
PHP-Code:
<html>
<head>
<title></title>
<body>
<?php
if ($termin == "" ){
echo ("Bitte etwas ankreuzen");
exit;
}
else{
// ---------------
// define options
// ---------------
$file_data = 'voting.txt'; // text file name (CHMOD 777);
$cookie_duration = 3600; // how long cookie remains (3600 = 1 hour)
$cookie_title='voting_1';
// prevent browser cache
// ---------------------
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
function readData()
{
GLOBAL $file_data, $_COOKIE, $cookie_title;
// --------------------
// load file into array
// --------------------
$fp = file($file_data);
// -----------------------------
// print each value of the array
// -----------------------------
while(list($line,$value) = each($fp))
{
// --------------------------------
// replace the newline with the '&'
// --------------------------------
print "&" . eregi_replace("\r\n","",$value);
}
if(isset($_COOKIE["$cookie_title"]))
{
print "&allow=false";
} else {
print "&allow=true";
}
}
// -------------------
// Save data to the
// text file
// -------------------
function saveData($num)
{
GLOBAL $file_data, $_COOKIE, $cookie_duration, $cookie_title;
if(isset($_COOKIE["$cookie_title"]))
{
die("registered=already voted");
}
if(number_format($num) < 1) die("registered=false");
$fp_array = @file($file_data);
$fp = @fopen($file_data,"r+");
$temp_string = '';
foreach($fp_array as $key => $value)
{
$line = explode('=',$value);
$theName = $line[0];
$theValue = eregi_replace("\r\n","",$line[1]);
if(substr($theName,0,5)=='votes')
{
$theValue = number_format(eregi_replace("\r\n","",$line[1]));
$matching_num = number_format(substr($theName,5,2));
if($matching_num==$num)
{
$theValue++;
}
}
$temp_string .= "$theName=$theValue\n";
}
@fwrite($fp,$temp_string);
@fclose($fp);
setCookie($cookie_title, time(), time() + $cookie_duration);
print "registered=true";
}
// -----------------
// Decisional switch
// -----------------
switch($_GET['action'])
{
case 'saveData':
saveData($_GET['num']);
break;
default:
readData();
break;
}
echo ("Vielen Dank für deine Stimme $name")
?>
</body>
</html>
Parse error: syntax error, unexpected $end in /vote.php on line 112
[MOD: Tags geändert]
Kommentar