PHP Guestbook Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
caseyd_dot_net
Forum Newbie
Posts: 4
Joined: Wed Nov 13, 2002 9:01 pm

PHP Guestbook Problem

Post 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
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post 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.
caseyd_dot_net
Forum Newbie
Posts: 4
Joined: Wed Nov 13, 2002 9:01 pm

Post 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
User avatar
Skywalker
Forum Contributor
Posts: 117
Joined: Thu Aug 29, 2002 3:33 am
Location: The Netherlands

Post 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
Post Reply