Re: [SMARTY] newbie: Escaped variables in form textareas??

From: Date: Mon, 01 Jul 2002 17:46:14 +0000
Subject: Re: [SMARTY] newbie: Escaped variables in form textareas??
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5126@lists.php.net to get a copy of this message
PHP actually automatically escapes quotes coming in from GET/POST/COOKIES. its on by default in most php distributions var_dump(ini_get("magic_quotes_gpc")); should tell you if its on or not -bok On 2/7/02 3:40 AM, Avern Williams banged a keyboard and produced the following weird but readable email: > Thanks, I was going to say that it seemed like smarty was putting in the > slashes by default. To test it I tried creating a php page with the > following content: > > --------------------------------- > <?php > > if ($action == "submit") { > require("Smarty.class.php"); > $smarty = new Smarty; > $smarty->assign("yourtext",$yourtext); > $smarty->display("formtest.tpl"); > } else { > print "<form action=\"/smarty/formtest.php\" > method=\"post\"><input > type=\"hidden\" name=\"action\" value=\"submit\">Enter your > text: <input > type=\"text\" name=\"yourtext\"><br><input > type=\"submit\"></form>"; > } > > ?> > --------------------------------- > > Then I created formtest.tpl to look like: > > --------------------------------- > You entered: <input type="text" name="yourtext" > value="{$yourtext}"> > --------------------------------- > > And when I tried it, if I entered text with a quote, it didn't show up after > submission. Is smarty intended to behave this way by default? > > Thanks for the info on stripslashes. I'll give that a try. > > thanks again! > Avern > > >> From: Ben Godfrey <ben@hypothetical.co.uk> >> To: "Avern Williams" <avern@hotmail.com> >> CC: smarty-general@lists.php.net >> Subject: Re: [SMARTY] newbie: Escaped variables in form textareas?? >> Date: Mon, 1 Jul 2002 18:09:00 +0100 >> >> >> You need to run PHP's stripslashes function on the form data. >> >> Either do it in the application or, if this isn't possible, write a Smarty >> modifier to wrap stripslashes. >> >> Ben >> >> >> On Monday, July 1, 2002, at 05:51 , Avern Williams wrote: >> >>> Hi, >>> >>> I have a textarea field for comments in a web form. If there is no >>> problem with the form, then the comment gets entered into a database and >>> is immediately display in an html page (this part works fine). However, >>> if there is a problem with the form, I've asked a smarty template to >>> redisplay the form, showing the visitor's original comment as the default >>> value in the comment field. >>> >>> The problem is that if their comment has a quote character, then the >>> backslashes show up when the form is redisplayed. I know the backslashes >>> normally help the quotes to be displayed properly, but is there a way to >>> have smarty show the comments variable without the backslashes? >>> >>> thanks, >>> Avern >>> >>> _________________________________________________________________ >>> Join the worldís largest e-mail service with MSN Hotmail. >>> http://www.hotmail.com >>> >>> >>> -- Smarty General Mailing List (http://smarty.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> >> >> >> -- >> Smarty General Mailing List (http://smarty.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> > > > > > _________________________________________________________________ > Send and receive Hotmail on your mobile device: > http://mobile.msn.com >

« previous php.smarty.general (#5126) next »