Forum Moderators: open

Message Too Old, No Replies

Dealing with & reg ; and & trad ; in forms

How to deal with special characters

         

vccubed

11:42 pm on Aug 20, 2007 (gmt 0)

10+ Year Member



When we enter special characters into forms it only works correctly once, ie the & reg ; (without spaces) is saved into a MySQL database and when retrieved and displayed the (R) character is presented properly. However, when I load from the database and populate a form for editing the (R) shows up in the data entry portion of the form instead of the originally entered & reg ; html code.

I have a ton of replace statements to deal with this for reg; copy; trad; ... surely there is a simple cleaner method that I'm just too stupid to think of.

A snippet of code would be appreciated. I'm using ASP with MySql.

phranque

11:58 pm on Aug 20, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



you should use html escaping on your form field input:
"<" characters should be converted to "&lt;", ">" characters should be converted to "&gt;", "&" characters should be converted to "&amp;", and quote characters should be converted to "&quot;".

then for example, your "&trad;" is actually inserted into the form input field in your document as "&amp;trad;" but rendered as "&trad;".