Re: quotes in text.
| From: | John W. Holmes | Date: | Fri, 16 Jul 2004 16:19:55 +0000 |
| Subject: | Re: quotes in text. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-190728@lists.php.net to get a copy of this message | ||
Ed Curtis wrote:
I'm having some difficulty with quotation marks, both single and double, input via a textarea in a form. Here's and example of text. Trying out the "Special Character" thing. Page 1 is the form. Page 2 is the data shown back to the user. original POST data is not touched. NO stripslashes original typed text is show to the user by stripslashes($thistext) original POST data is transferred to next page via hidden input field without stripping slashes. Page 3 posts the data to a MySQL database. original POST data is not touched. No stipslashes. Text gets cut off in database (Trying out the) What exactly do I need to do to the text so that any quotation marks (single or double) get input into the database.Let's say you have $_POST['text'] from the user. To display the value back to the user with magic_quotes_enabled, you'd do this: echo htmlentities(stripslashes($_POST['text'])); To put the value into a hidden form element, you'd do this: <input type="hidden" name="text" value="<?=htmlentities(stripslashes($_POST['text']))?>"> Now, $_POST['text'] will come out correctly on Page 3. Since you seem to have magic_quotes_gpc enabled, you can put the value directly into your query. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com