The code below is for a guestbook that I have on my site here:
http://www.hypertheory.com/fenix/guestbook/guestbook.php3
For some reason, it is putting foward slash before every apostrophe. I went through the code line by line, but couldn't find the reason.
If any of u can see what's causing, could u please let me know?
Thanks,
Chris
Here's the code:
<script language="php">
$PostPage = "post.htm";
$gbPage = "index.php3";
if (($name == "") AND ($email == "") AND ($comments == "")):
$error1 = "<font size='3' class='s4' color='red' face='Arial, Helvetica'><STRONG>It appears as if you've tried to submit a blank form:</STRONG></font><br>";
echo $error1;
include($PostPage);
elseif ($form == preview):
echo("
<head>
<title>Untitled</title>
</head>
<style type='text/css'>
<!--//
.s5 {font-size: 20px; font-family: arial,helvetica}
.s4 {font-size: 18px; font-family: arial,helvetica}
.s3 {font-size: 13px; font-family: arial,helvetica; letter-spacing: 1px}
//-->
</style>
<BODY>
<P><font size='3' class='s4' face='Arial, Helvetica'>Confirm your comment and submit, or <a href='index.php3'>view the guestbook</a> without making an entry</FONT></P>
<P>
<font size='3' class='s4' face='Arial, Helvetica'>Add a message to my guest book:</FONT>
<FORM ACTION='guestbook.php3' METHOD=POST>
<P>
<font size='3' class='s4' face='Arial, Helvetica'>
Name:<BR>
<INPUT TYPE=text NAME=name SIZE=30 maxlength=80 value=$name><BR>
Email:<BR>
<INPUT TYPE=text NAME=email SIZE=30 maxlength=80 value=$email><BR>
Notes:
<BR>
<TEXTAREA NAME=comments ROWS=10 COLS=30 WRAP=virtual>$comments</TEXTAREA>
<BR><BR>
Check here if you used HTML tags in any field: <INPUT TYPE=checkbox NAME=html value='1'");if ($html == 1):$xbox = CHECKED; echo $xbox; else:'';endif;echo("><BR>
</FONT>
</P>
<P><font size='2' class='s3' face='Arial, Helvetica'><INPUT TYPE=submit NAME=gb VALUE='Add Message'> Please press only once: this may take a moment (or two).</FONT>
</FORM></P>
</BODY>
");
else:
$gbFile = "messages.txt"; // Location of link database file
$gbPage = "index.php3"; // Link page file
if ($html == 1):
$allowHTML = 1; // To allow HTML in site description 1 = Yes, 0 = No
else:
$allowHTML = 0; // To allow HTML in site description 1 = Yes, 0 = No
endif;
$notify = 0; // Would you like to be notified when a link is added? 1 = yes, 0 = No
$my_email = "you@youremailaddress.com"; // Enter your email address
$subject = "New Guestbook Entry" ; // Enter the subject of the notification email
/
Code Follows Below
/
$page = $gbFile;
if ($allowHTML == 0):
$name = ereg_replace("<","<",$name);
$name = ereg_replace(">",">",$name);
$email = ereg_replace("<","<",$email);
$email = ereg_replace(">",">",$email);
$url = ereg_replace("<","<",$url);
$url = ereg_replace(">",">",$url);
$urltitle = ereg_replace("<","<",$urltitle);
$urltitle = ereg_replace(">",">",$urltitle);
$referral = ereg_replace("<","<",$referral);
$referral = ereg_replace(">",">",$referral);
$comments = ereg_replace("<","<",$comments);
$comments = ereg_replace(">",">",$comments);
endif;
$filename = "messages.txt";
$fd = fopen( $filename, "r" );
$current = fread( $fd, filesize( $filename ) );
fclose( $fd );
$comments = ereg_replace("\n","<BR>",$comments);
$fileMessage = "<P><b><font size='2' color='#FFFF00' class='s3' face='Arial, Helvetica'>Name: </b></font><font size='2' color='#ffffff' class='s3' face='Arial, Helvetica'>$name</font>\n";
$fileMessage .= "<br><font size='2' color='#FFFF00' class='s3' face='Arial, Helvetica'><b>Date: </b></font>";
$fileMessage .= ("<font size='2' color='#ffffff' class='s3' face='Arial, Helvetica'>\n");
$fileMessage .= (date("l dS of F Y h:i:s A"));
$fileMessage .= ("</font>\n");
$fileMessage .= "</font><font size='2' color='#FFFF00' class='s3' face='Arial, Helvetica'><br><b>E-mail:</b></font>\n";
$fileMessage .= "<font size='2' color='#ffffff' class='s3' face='Arial, Helvetica'>$email</font>\n";
// $fileMessage .= "<br><b>Email: </b><a href=\"mailto:$email\">$email</a>\n";
//$fileMessage .= "<br><b>Reference: </b><a href=\"$url\">$url</a>\n";
// $fileMessage .= "<br><b>How did you hear about this site? : </b>$referral\n";
$fileMessage .= "<br><font size='2' color='#FFFF00' class='s3' face='Arial, Helvetica'><b>Comments:</b></font>\n";
$fileMessage .= "<br><font size='2' color='#ffffff' class='s3' face='Arial, Helvetica'>$comments</font>\n";
$fileMessage .= "<br><br><br><center><img src='black.gif' width=100% height=1 border=0></center>\n";
$fileMessage .= "$current\n";
if (file_exists("$page")):
$cartFile = fopen("$page","w+");
fputs($cartFile,$fileMessage);
fclose($cartFile);
else:
$cartFile = fopen("$page","w");
fputs($cartFile,$fileMessage);
fclose($cartFile);
endif;
// EMAIL THE NEW POST
if ($notify == 1):
$comments = ereg_replace("<BR>","\n",$comments);
mail
(
"$my_email",
"Example Issues List Entry",
"Name : $name
Email : $email
Note:
$comments\n
",
"From: $email\n"
);
endif;
//set vars for help checking against double entries
$name_chk = $name;
$email_chk = $email;
$comments_chk = $comments;
include($gbPage);
//endif from very top where checking if form is empty
endif;
</script>