Handling special chars (apostrophes,backslashes,etc) in html forms across multiple pages
Posted on 2004-11-19
In my html forms, I have textfields and textarea's that will contain backslashes and/or apostrophes. The problem is I have multiple forms across multiple pages.
I post the data from the first page onto the second page, and its put into hidden fields. Special characters are automatically escaped with a backslash. The problem is, if the user goes back, the data is posted to the first page and the special characters are escaped again!
So for example, on page 1, if a user enters "I can't type" in the textarea and hits submit:
Page 2 will contain a hidden input field with the value "I can\'t type" and some other input boxes. If the user hits back, the data is submitted to page 1.
Page 1 will get the posted data as "I can\\\'t type" and then my php script will put that data into the text area.