Page 1 of 1
PHP Guestbook Problem
Posted: Sat Jan 18, 2003 9:37 pm
by caseyd_dot_net
I'm using a PHP guestbook I wrote, but I'm having a bit of a problem. When you post to it, it opens and writes to a .txt file (I don't have a mySQL account on the server it's on), and then uses include() to print it in the HTML. When it writes to the file, though, it escapes characters like returns and single quotes with '///' which looks ridiculous. I've tried a lot to get it to stop, but I'm stumped.
Thanks,
Casey Dentinger
Posted: Sat Jan 18, 2003 10:17 pm
by evilcoder
PHP has a function called stripslashes.
Now i can see the part of your code that places the code from the .txt file onto the page. If i could see that i will be able to help you fix it immediately.
Posted: Sun Jan 19, 2003 12:19 pm
by caseyd_dot_net
Here's what I'm using to write to the file:
<?php
$date = date("n\/j\/y");
$info = "
<div class='GuestBook'>
<p class='Info'>
$name
<br />
$REMOTE_ADDR
<br />
$email
<br />
$date
</p>
<br />
<br />
<p class='Message'>
$message
</p>
</div>
";
if (isset($submit) && isset($message)) {
escapeshellcmd($name, $email, $message);
$fd = fopen("post-it.txt", "a+");
fputs($fd, stripslashes($info));
fclose($fd);
}
?>
As I'm sure you could guess, all this data is passed to this by an HTML form and then printed with <?php include() ?>.
Casey Dentinger
Posted: Mon Jan 20, 2003 7:15 am
by Skywalker
If you also have problems with enters and spaces then look for html special characters, because those do aplay the enters and spaces.
Greathings Skywalker