[thelist] Dealing with special characters in forms

sasha spam at bittersweet2.com
Fri Jan 3 12:24:01 CST 2003

On Fri, 3 Jan 2003 13:13:12 -0500, Michael Caplan <michael at eggplant.ws>

> hi,
> I'm having a problem with a form filled textarea and special characters.
> When the form is submitted to be parsed by a PHP script, all the special
> character entities are presented to the script as translated text.
> An example:
> The user is presented with a form that has the following predefined
> textarea:
> <textarea id="b88" name="body[88]" cols="72" rows="12">
> <p>&pound; &lt;= crazy</p>
> </textarea>
> When the form is submitted, the data in the textarea is translated so
> that
> the special character codes are replaced with there text equivalent.
> The weird thing is if the user is presented with a blank textarea and
> they
> enter "<p>&pound; &lt;= crazy</p>", the browser will retain the special
> character codes.
> So... the million dollar question: How do you ensure that your special
> characters are maintained in there encoded format upon submission?
> Thanks,
> Michael
> PS - for what it is worth, my page uses the following character set:
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
> />

For displaying the contents in a form, try converting all &'s into &amp; so
that an html entity like &lt; displays as &amp;lt; in the source (which
then displays as &lt; in the form).

It has nothing to do with your charset or anything else, it's just how
forms display stuff.


More information about the thelist mailing list