Jump to content

Simple Shoutbox Felp.


Mailik

Recommended Posts

Hey guys. I'm really sorry if this comes across as such a noob question.

 

What it is, is that I have a basic shoutbox. And when I type in things such as "Didn't" It appears as "Didn/'t" And I'm just wondering on how to fix it so that it doesn't do that, I thought about a filteration where when people did typed " ' " it would replace " ' " with nothing. But felt that this wasn't resolving the problem, maybe shoving it aside. And even if it did fix the problem, I couldn't get it to work.

 

Here is what I have, any help would be greatly appreciated.

 

<?php

$name = $_POST['Name']; 	
$email = $_POST['Email'];		
$comments = $_POST['Comments'];
$timedate = date("M d, Y (g:i a)", time() + 7200);

if ($name == "" or $comments == "") {
echo "Your name or comment was left blank! Try again. <br /><br />";
} else {
$oldinfo = file_get_contents("data.txt");
$guestbookdata = fopen("data.txt", "w+");
fwrite($guestbookdata, "<table><td><div class=\"post\"><b>Name:</b> <a href=\"mailto:{$email}\">{$name}</a> <br> <b>Time:</b> <em>{$timedate}</em> <br />\n");
fwrite($guestbookdata, "<b>Comments:</b><br> $comments <br><br></td></table></div>\n \n");
fwrite($guestbookdata, "$oldinfo");
fclose($guestbookdata);
}
?>

Link to comment
Share on other sites

Hi, thanks for helping out.

I added the code that you gave me and get the message 'Magic quotes is on!'

 

So I tried using the stripslashes code afterwards that you had posted. So the code I have now looks like;

 

<?php

$name = stripslashes($_POST['Name']   
$email = stripslashes($_POST['Email']
$comments = stripslashes($_POST['Comments']
$timedate = date("M d, Y (g:i a)", time() + 7200);

if ($name == "" or $comments == "") {
   echo "Your name or comment was left blank! Try again. <br /><br />";
} else {
   $oldinfo = file_get_contents("data.txt");
   $guestbookdata = fopen("data.txt", "w+");
   fwrite($guestbookdata, "<table><td><div class=\"post\"><b>Name:</b> <a href=\"mailto:{$email}\">{$name}</a> <br> <b>Time:</b> <em>{$timedate}</em> <br />\n");
   fwrite($guestbookdata, "<b>Comments:</b><br> $comments <br><br></td></table></div>\n \n");
   fwrite($guestbookdata, "$oldinfo");
   fclose($guestbookdata);
}
?>

 

When I go to post, I get the error

"Parse error: parse error in post.php on line 5"

Link to comment
Share on other sites

stripslashes() is not dependent on it, its a way of neutralizing the effects of it.

If magic_quotes_gpc is off, you wouldn't need to use strip slashes (in this case) but strip slashes would still work on a string.

Sorry I sent you the code with the ")" outside the semicolon. Need more coffee or new glasses, or both :-)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.