hues Posted May 10, 2006 Share Posted May 10, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/9461-problem-with-text-box-in-a-form/ Share on other sites More sharing options...
wildteen88 Posted May 10, 2006 Share Posted May 10, 2006 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 #. Quote Link to comment https://forums.phpfreaks.com/topic/9461-problem-with-text-box-in-a-form/#findComment-34923 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.