I have a WordPress site with a form that people can fill out. The data is put into the database and used to create a simple one-page website. If the user wants to edit the website, the data is pulled out of the database and used to pre-populate the original form, where the user can change what they want and resubmit the form. The problem is that if the text entered into the form contains an apostrophe, as in “You’ll love this product” when the text is read from the database and put into the value attribute for the input element, it displays in the form as “You’ll love this product.” An if that is submitted, the next time it comes back out of the database and into the form it’s “You’ll love this product.
How should I be handling this form text to keep these “” escape characters from being generated and displayed?
Have you tried stripslashes(), regarding the line breaks just use the nl2br() function.
Example:
Note: double slashes will turn to single slashes
You should probably set-up your own function, something like: