Hi, bin total verzweifelter anfänger. hab auf meiner page ein php gästebuch eingefügt. jedoch folgendes problem. immer wenn jemand im text einen zeilenumbruch macht (enter drückt) verschiebt sich das ganze gästebuch total. Könnt ihr mir vielleicht sagen was im skript falsch ist? Vielen Dank im Voraus. Lg, Alex
<?php
$file='./gaestebuch.txt';
error_reporting(1);
$mode=$_GET['mode'];
if($mode!='view' && $mode!='sign') $mode=$_POST['mode'];
if($mode!='view' && $mode!='sign') $mode='sign';
$name=$_POST['name'];
$site=$_POST['site'];
$comments=$_POST['comments'];
$date=date('l, F dS, Y (g:i A T)');
$self=$_SERVER['PHP_SELF'];
($handle=fopen($file,'a+') or die("Could not open file: $file"));
if($mode=='sign')
{
if($name!='') fwrite($handle,"$date\n$name\n$site\n$comments\n");
echo "<form method='post' action='$self'>
<input type='hidden' name='mode' value='sign'>
<b>date</b>: $date
<p><b>name</b>: <input type='text' name='name'>
<p><b>email</b>: <input type='text' name='site'>
<br><br><textarea name='comments' cols='30' rows='5'></textarea>
<p><input type='submit' value='send'>
</form>
<br><b><a href=\"$self?mode=view\">View my Guestbook</a></b>";
}
else
{
$a=array_reverse(file($file));
for($i=0;$i<count($a)-3;$i+=4)
{
$web=$a[$i+1];
if(substr($web,0,7)!='http://') $web=" $web";
echo '<b>date</b>: '.htmlentities($a[$i+3]);
echo '<p><b>name</b>: '.htmlentities($a[$i+2]);
echo "<p><b>email</b>: <a href='mailto:\"$web'>".htmlentities($web).'</a>';
echo '<p><b>text</b>:<br>'.htmlentities($a[$i]);
echo '<p><hr><p>';
}
echo "<b><a href=\"$self?mode=sign\">Sign the Guestbook</a></b>";
}
fclose($handle);
?>
<?php
$file='./gaestebuch.txt';
error_reporting(1);
$mode=$_GET['mode'];
if($mode!='view' && $mode!='sign') $mode=$_POST['mode'];
if($mode!='view' && $mode!='sign') $mode='sign';
$name=$_POST['name'];
$site=$_POST['site'];
$comments=$_POST['comments'];
$date=date('l, F dS, Y (g:i A T)');
$self=$_SERVER['PHP_SELF'];
($handle=fopen($file,'a+') or die("Could not open file: $file"));
if($mode=='sign')
{
if($name!='') fwrite($handle,"$date\n$name\n$site\n$comments\n");
echo "<form method='post' action='$self'>
<input type='hidden' name='mode' value='sign'>
<b>date</b>: $date
<p><b>name</b>: <input type='text' name='name'>
<p><b>email</b>: <input type='text' name='site'>
<br><br><textarea name='comments' cols='30' rows='5'></textarea>
<p><input type='submit' value='send'>
</form>
<br><b><a href=\"$self?mode=view\">View my Guestbook</a></b>";
}
else
{
$a=array_reverse(file($file));
for($i=0;$i<count($a)-3;$i+=4)
{
$web=$a[$i+1];
if(substr($web,0,7)!='http://') $web=" $web";
echo '<b>date</b>: '.htmlentities($a[$i+3]);
echo '<p><b>name</b>: '.htmlentities($a[$i+2]);
echo "<p><b>email</b>: <a href='mailto:\"$web'>".htmlentities($web).'</a>';
echo '<p><b>text</b>:<br>'.htmlentities($a[$i]);
echo '<p><hr><p>';
}
echo "<b><a href=\"$self?mode=sign\">Sign the Guestbook</a></b>";
}
fclose($handle);
?>
Kommentar