simple php guestbook----with bug
Posted: Fri Mar 12, 2004 6:08 pm
hi, im new to PHP and treid to create a simple guestbook
i think i got it right but it apears that every NEW entery
erase all the previous ones and shows only her.
yes, i CAN chane the r+ in line 32 to a+
but i want the latest messages to be displayed first
hope someone can help
with respect
adam
p.s. please ignore the "wired" signing on the buttons, its just hebrew
<html><head><title>forum</title></head>
<body background=home_back.jpg>
<form method="get" action="">
<b>
:םש<br>
<input type="text" name="name" size="8"><br>
:העדוה</b><br>
<textarea name="comments" cols=30 rows=5></textarea><br><br>
<input type="submit" value="שלח" name="submit" style=
"width:50;text-align:center;cursor:hand">
</form><br>
<?php
if(!empty($name)&&!empty($comments))
{
$data =strrev($comments)." :<b>".strrev($name)."</b>".
"<img src=rec_purple.gif><br>";
$file = fopen("0forum.txt","r+");
fwrite($file,$data);
fclose($file);
}
//display all messages
$file=fopen("0forum.txt","r+");
fpassthru($file);
?>
</body></html>
i think i got it right but it apears that every NEW entery
erase all the previous ones and shows only her.
yes, i CAN chane the r+ in line 32 to a+
but i want the latest messages to be displayed first
hope someone can help
with respect
adam
p.s. please ignore the "wired" signing on the buttons, its just hebrew
<html><head><title>forum</title></head>
<body background=home_back.jpg>
<form method="get" action="">
<b>
:םש<br>
<input type="text" name="name" size="8"><br>
:העדוה</b><br>
<textarea name="comments" cols=30 rows=5></textarea><br><br>
<input type="submit" value="שלח" name="submit" style=
"width:50;text-align:center;cursor:hand">
</form><br>
<?php
if(!empty($name)&&!empty($comments))
{
$data =strrev($comments)." :<b>".strrev($name)."</b>".
"<img src=rec_purple.gif><br>";
$file = fopen("0forum.txt","r+");
fwrite($file,$data);
fclose($file);
}
//display all messages
$file=fopen("0forum.txt","r+");
fpassthru($file);
?>
</body></html>