Re: Hidden Input and Quotes?

From: Date: Sat, 12 May 2001 01:39:53 +0000
Subject: Re: Hidden Input and Quotes?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-52531@lists.php.net to get a copy of this message
Jason Caldwell wrote: > If I have a text box and enter data into that text box with "quotes" around > some of the text... and I want to throw that text into a HTML Hidden Input > Field (on my next screen for example) -- the quotes will somehow jackup or > truncate that text... because HTML uses "quotes" within in the Hidden Input > Field. > > So my question is, should I (or, really, can I) encode it? My thinking is I > want to encode it with the htmlspecialchars() function... however, > eventually, all the data within the Hidden Input Boxes will be stored into > my mySQL database, so I'll want to decode it before I send it (restoring the > quotes)... is there a way to decode the htmlspecialchars() function? Or, is > there a better way to do this (*without* creating a session)? -- I want to > use Hidden Input Fields. An easier thing to do would be *not* to use htmlspecialchars(), but instead replace all instances of " with " . That's assuming your hidden input field uses " instead of ' to quote the attribute values. You can just do: ereg_replace("\"", """, $data); Then you don't have to decode anything to restore the quotes and other characters that have been changed. The " will be translated back into " when your form is submitted. Young

« previous php.general (#52531) next »