Back Slashes appear in my mail message?

I have a contact form which submits to the php mail command, all works fine, but if you put in the mail message " or ’ i.e. I would like the 12" Cake Tin or Paul’s Cake Tin, then the delivered email adds a back slash before the " or ’

Any ideas why?

Form Code:


Your Name:
Your Email:

Your Telephone Number:

Your Message:
Please enter the CAPTCHA code from the above image here:

submit code:


// The rest of your Contact Page code goes here
if( $_SESSION[‘6_letters_code’] == $_POST[‘CAPTCHA’] && !empty($_SESSION[‘6_letters_code’] ) ) {
$to = "[email protected]";
$email_subject = “Email enquiry from”;
$name = $_POST[‘name’];
$email = $_POST[‘email’];
$tel = $_POST[‘tel’];
$message = $_POST[‘message’];
$headers = “From: $email”;
$email_body = "You have received a new message from " . $name . ".\n\nEmail Address: " . $email . ".\n \nTelephone Number: " . $tel . ".\n \nMessage: " . $message;
echo ‘

Thank You for your message, we will be in touch soon.

} else {
echo “Sorry, you have provided an invalid CAPTCHA code. Please CLICK HERE to try again.”;
// Destroy session after message is sent
?> [/code]

In your code you rely on magic_quotes_gpc = Off. But it seem that you have this option turned On in your php.ini (that’s why you get quote symbols escaped with backslash). Try to set magic_quotes_gpc = Off (you can do this in php.ini, or using .htaccess)

Sponsor our Newsletter | Privacy Policy | Terms of Service