views:

169

answers:

2

Hello guys,

I'm testing a PHP mail form, a very barebones one, found here:

<?php

    if(isset($_POST['submit']))

    {

        //The form has been submitted, prep a nice thank you message

        $output = '<h3>Thanks for your message</h3>';


        //Deal with the email

        $to = '[email protected]';

        $subject = 'you have a mail';



        $contactname = strip_tags($_POST['contactname']);

        $adress = strip_tags($_POST['adress']);

        $contactemail = strip_tags($_POST['contactemail']);

        $textmessage = strip_tags($_POST['textmessage']);



        $boundary =md5(date('r', time())); 



        $headers = "From: My Site\r\nReply-To: [email protected]";





        $message = "Name: ".$contactname."\n";

        $message .= "Adress: ".$adress."\n";

        $message .= "E-mail: ".$contactemail."\n";

        $message .= "Message: ".$textmessage."\n";



        mail($to, $subject, $message, $headers);

    }

?>

The problem is I'm receiving an unwanted slash "\" everytime I write a single or a double quote in my message, so "I'm" appear as "I\'m" in my mailbox.

I know it have to do with the way PHP distinguishes code quotes from only lecture quotes, but I wouldn't know what to add in my form to get it properly running.

Any help is appreciated,

+4  A: 

The easiest thing to do is to turn magic quotes off in php.ini,

magic_quotes_gpc=false

If you can't do that, you need to remove slashes like this,

if (get_magic_quotes_gpc()) {
    foreach($_POST as $k => $v) {
       $_POST[$k] = stripslashes($v);
    }
}
ZZ Coder
+1  A: 

you can try stripslashing your message , something like :

$message = stripslashes($message);
Puaka
Thanks guys it worked
Peanuts