Hi,
This is really annoying cos it seems so easy.
I've created two php files: One with a form, and the second with a preview page that displays the submitted data from that form. The second file also contains a mail function which is called when the user clicks send if they're happy with the preview. Then the submitted data gets sent to my email address. Pretty straight forward, right?
My problem happens if the user has written something that contains double quotes when they filled out the form. Anything between double quotes AND after will not display when the data is emailed to me. WHY?
Single quotes work fine. It's just the double quotes.
EXAMPLE
If the user writes:
Hello there "how are you" ?
All I get sent is:
Hello there
This is the contents of the mail function that sends the email:
$_POST['username'] = stripslashes($_POST['username']);
$username = $_POST['username'];
$_POST['useremail'] = stripslashes($_POST['useremail']);
$useremail = $_POST['useremail'];
$_POST['userphone'] = stripslashes($_POST['userphone']);
$userphone = $_POST['userphone'];
$_POST['comments'] = stripslashes($_POST['comments']);
$comments = $_POST['comments'];
$mailto = "myname@somewhere.com";
$subject = "Website feedback";
$message = "This Feedback was sent by:\n" .
"$username\n" .
"---------Website Feedback and Enquiries---------\n\n" .
"Website user name:\n" . "$username" .
"\nWebsite user email address is: \n" . " $useremail" .
"\nWebsite user phone number:\n" . "$userphone" .
"\nFeedback:\n" . "$comments" .
"\n\n------------------------------------------------------------\n" ;
$success = mail($mailto, $subject, $message, "From: \"$username\" <$useremail>\nReply-To: \"$username\" <$useremail>");
if ($success) {
header ("location:[url]http://www.somewhere.com/thanks.html[/url]");
}
else header ("location:[url]http://www.somewhere.com/error.html[/url]");
}
To display the preview page I send all of the submitted data from page one through a validation function in page two. The data comes out of the validation as a variable and that variable is displayed in the preview message. So is the above code the right way to send that data to my email address??
Surely it's not that complicated to solve,
Thanks for any help.