note 14240 added to function.get-magic-quotes-gpc.php

From: Date: Mon, 23 Jul 2001 19:12:50 +0000
Subject: note 14240 added to function.get-magic-quotes-gpc.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-15718@lists.php.net to get a copy of this message
A common need would be to post the results of a submitted form back into the contents of another HTML form. For example, if a data field failed to validate you might re-present the original form with the field data as entered and ask the user to make changes. How to do this, in an environment where magic_quotes_gpc may or may not be set? Using ini_set("magic_quotes_gpc",0) in the php script as previously suggested doesn't work, becuase by the time the ini_set is called, the get and post vars have already been parsed and quoted. My solution is this: <? function formvar ($name) { $var = $GLOBALS[$name]; if (get_magic_quotes_gpc()) $var = stripslashes($var); print htmlspecialchars($var); }; ?> <form> <input name="foo" value="<?formvar("foo")?>"> </form> http://www.php.net/manual/en/function.get-magic-quotes-gpc.php

« previous php.notes (#15718) next »