' (Single Quotes) in user inputs
| From: | Ben | Date: | Thu, 14 Oct 2004 02:49:25 +0000 |
| Subject: | ' (Single Quotes) in user inputs | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-199456@lists.php.net to get a copy of this message | ||
I am running into a problem with user input when a user inputs a single
quote in the form field, such as entering O'Brien as a last name. When the
user enters this, PHP adds a \ in front of the single quote, and then if the
form is submitted again, adds a \ in front of the \ and again in front of
the single quote. Example:
<INPUT TYPE="TEXT" NAME="lastName" VALUE="$lastName">
if the user enters a name containing a single quote, such as O'Brien, it
becomes
<INPUT TYPE="TEXT" NAME="lastName" VALUE="O\'Brien">
Upon submitting the form again, it become
<INPUT TYPE="TEXT" NAME="lastName" VALUE="O\\\'Brien">
Any ideas on dealing with this would be greatly appreciated.
Thanks.
Ben