Quotes, Double Quotes and Hidden Fields
| From: | Gareth Mulholland | Date: | Wed, 27 Dec 2000 21:31:20 +0000 |
| Subject: | Quotes, Double Quotes and Hidden Fields | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-32011@lists.php.net to get a copy of this message | ||
I've created a form which contains about 12 textareas and text inputs.
If a user inputs a string which contains a number of " and ' characters
then things get messy when the input is displayed for preview and is posted
in hidden fields for final posting.
I kept finding that data was being lost when input strings contained these
quotes and have resorted to the following:
$contact_name = htmlentities(stripslashes($contact_name));
$contact_email = htmlentities(stripslashes($contact_email));
$contact_add = htmlentities(stripslashes($contact_add));
$contact_tel = htmlentities(stripslashes($contact_tel));
$contact_fax = htmlentities(stripslashes($contact_fax));
$url = htmlentities(stripslashes($url));
$comments = htmlentities(stripslashes($comments));
This seems very clumsy and probably unnecessary - is there a better way of
doing this?
Thanks
Gareth