RE: [PHP] Quotes getting screwed up in form fields
| From: | John Holmes | Date: | Sat, 27 Jul 2002 15:28:36 +0000 |
| Subject: | RE: [PHP] Quotes getting screwed up in form fields | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-109975@lists.php.net to get a copy of this message | ||
> If someone enters this into a field...
>
> New York "City"
>
> and I need to re-display it in the field (if an error occurred, for
> example), this is what's in the field...
>
> New York \
>
> I have another multi-line text field that I used quotes in and this
> doesn't
> happen with that field, even though they are both being treated in the
> same
> manner. What am I missing?
If you look at your source code, you'll see that the entire string is
there. It will look like this:
Value="New York\"City\""
HTML doesn't know that \ is used to escape the " character. It just sees
the string "New York\" and treats the rest as an unknown attribute.
So, to do it correctly, you should use this:
Value="<?=htmlentities(stripslashes($your_text))?>"
---John Holmes...