RE: [PHP] POSTing HTML into a database
| From: | Ford, Mike [LSS] | Date: | Tue, 08 Jan 2002 10:41:00 +0000 |
| Subject: | RE: [PHP] POSTing HTML into a database | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-79780@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: James Arthur [mailto:james@teamonkey.plus.com]
> Sent: 07 January 2002 21:41
<snip>
> For example, consider the string $body = "I am saying \"Hello\"";
>
> <input type="hidden" name="body" value="<?=$body>">
> is interpreted by the browser as
> <input type="hidden" name="body" value="I am saying
> "Hello"">
> And so we have a problem.
>
> What can I do about that?
Since this is generating HTML, you need to encode these characters as HTML entities -- consider
using the htmlspecialchars() function (see http://www.php.net/manual/en/function.htmlspecialchars.php)
or htmlentities() (see http://www.php.net/manual/en/function.htmlentities.php).
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211