jackofalltrades Posted August 12, 2008 Share Posted August 12, 2008 I am having a really strange problem. I generated this code from a product called PHP Form Wizard. I have a form and everything in the form is working fine except one strange thing. When the user submits the form it sends an email to the form owner. In the email message that is sent everything is fine except that any time there is an apostraphe (') in a word, when the email is sent it puts three lines before the ' in the message. For instance if the customer filled in "I don't know" the message the form owner gets says "I don\\\'t know" It is weird and annoying my customer. Attached is the PHP code. The form is at www.designfoundry.ie/contact.htm Thank you very much in advance. [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted August 12, 2008 Share Posted August 12, 2008 The code is applying addslashes() to all the form fields. Also, the php setting magic_quotes_gpc is probably on. The addslashes() in the script should not be there at all (they don't escape all the special characters that can break a database query and your code is not using a database anyway.) Unfortunately, your script cannot turn off magic_quotes_gpc. The preferred method to deal with magic_quotes_gpc is to turn them off globally in the master php.ini, a .htaccess file, or a local php.ini, because they have been eliminated in upcoming php6. If you cannot turn them off, your code will need to test if magic_quotes_gpc is on and apply stripslashes() to all the form fields. You cannot unconditionally apply stripslashes() because that would remove actual \ characters that someone entered if magic_quotes_gpc are not on. Quote Link to comment Share on other sites More sharing options...
jackofalltrades Posted August 12, 2008 Author Share Posted August 12, 2008 Thank you very much for such a great detailed response. I will try to give back to the community but I am not so good yet... unfortunately I am at the taking rather than giving stage right now. Soon I hope. Quote Link to comment 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.