Jump to content

Archived

This topic is now archived and is closed to further replies.

hues

problem with text box in a form

Recommended Posts

I have used a simple coment form for a website.
Everything is working fine, except that if a field contains \ in the input, the mail I recieve shows up \\ instead of one backslash.
this is the part of the code

$from="$email_address";
$message="$title $name $last_name\n$organization\n$mailingaddress\n$mailingaddress2\n$city $state $zip\n$phone\n$email_address\n$email_address2\n\n$comments\n";
if(mail($to,"Comments From NIA MPU",$message,"From: $email_address\n")) {
echo "Thanks for your comments.";
} else {
echo "There was a problem sending the mail. Please check that you filled in the form correctly.";

Someone suggested adding
$header .= "MIME-Version: 1.0rn";
$header .= "Content-Type: text/html; charset=iso-8859-1rn";

but still no help.

The form is working fine except this small problem, which the client has pointed out.

Share this post


Link to post
Share on other sites
it is becuase you are using addslashes and so addslashes will ad an extraslash infront of another \ to so it preserves \ in the script, otherwise php will strip the \ out.

You might want to use stripslashes when sending the email or converr \'s into there html equivilent which is [b]& #92;[/b] (without the space)

You can do this by doing this:
[code]$message = str_replace("\\", "& #92;", $message);[/code]
That code converts a \ in to its html equivilent.
NOTE: before using the code above make sure you remove the space between the & and the #.

Share this post


Link to post
Share on other sites

×

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.