Folgendes kommt bei der verwendung des nachfolgenden Scripts:
Notice: Undefined variable: action in c:\home\phpkurs\message.php on line 34
script:
Notice: Undefined variable: action in c:\home\phpkurs\message.php on line 34
script:
PHP-Code:
<form action="message.php?action=message" method="post">
<INPUT TYPE=TEXT value="name" style="font-size:8pt; border-style:solid; font-weight: normal; font-family: Verdana,Arial; background-color: #FFFFFF; color: #222222; border-color: #8792BB;" NAME="name" SIZE=18 MAXLENGTH=15>
<br><INPUT TYPE=TEXT value="kommentar" style="font-size:8pt; border-style:solid; font-weight: normal; font-family: Verdana,Arial; background-color: #FFFFFF; color: #222222; border-color: #8792BB;" NAME="kommentar" SIZE=18 MAXLENGTH=100>
<br><INPUT type="submit" value="senden">
</form>
<?PHP
function format($text)
{
$text = strip_tags($text);
$text = nl2br($text);
$erlaubt = "# abcdefghijklmnopqrstuvwxyzABCEDFGHIJKLMNOPQRSTUVWXYZ,.;<>+-/[]{}=?´$:äÄöÖüÜß*@!§%&_'1234567890";
$text2 = "";
$leerzeichen=0;
for ($i=0; $i<strlen($text);$i++)
{
$letter = substr($text, $i, 1);
if ($letter!=" ") $leerzeichen++;
if ($letter==" ") $leerzeichen=0;
if ($leerzeichen>15)
{
$text2 = $text2 . " ";
$leerzeichen = 0;
}
if (strpos($erlaubt,$letter)>0) $text2 = $text2 . $letter;
}
return($text2);
}
// hier liegt der fehler aber ich weiss nicht wieso...
if (($action=="message") && ($name!="") && ($name!="name") && ($kommentar!="kommentar") && ($kommentar!=""))
{
global $REMOTE_ADDR; //IP-Adresse des Besuchers
$logfile = "ip.log";
if(!file_exists($logfile)){$datei = fopen($logfile,"w+");fwrite($datei,"100.0.0.0"); fclose($datei);}
$f=fopen($logfile,"r");
$ips = fgetcsv($f,10000,"|");
fclose($f);
$locked=false;
if($ips[0]==$REMOTE_ADDR) $locked=true;
if($locked==false)
{
$f=fopen($logfile,"w");
fwrite($f,$REMOTE_ADDR);
fclose($f);
}
if ($locked==false)
{
$file = fopen("message.txt","r");
$i="1";
while($msg[$i] = fgetcsv($file,1000,"#"))
{
$i++;
}
$msg[0][0] = date("d.m.y H:i");
$msg[0][1] = format($name);
$msg[0][2] = format($kommentar);
fclose($file);
$file = fopen("message.txt","w");
for ($y=0;$y<$i;$y++)
{
fwrite($file, $msg[$y][0]."#".$msg[$y][1]."#".$msg[$y][2]."#\n");
}
fclose($file);
}
}
$messagefile = fopen("message.txt","r");
$i=0;
while($msg = fgetcsv($messagefile,1000,"#"))
{
$i++;
if ($i<=10) echo "<p><font face=Arial size=-1><u><sub>$msg[0] | $msg[1]</sub></u><br>$msg[2]";
}
fclose($messagefile);
?>
Kommentar