Re: Easier way to clean GET Variables ?
| From: | Jasper Bryant-Greene | Date: | Thu, 25 Aug 2005 03:12:51 +0000 |
| Subject: | Re: Easier way to clean GET Variables ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-221309@lists.php.net to get a copy of this message | ||
Graham Anderson wrote:
Is there a way to loop thru all of these GET requests by: putting the GET variables into an array processing the variable strings with trim/striptags/etc in a loop exploding the variables back out into separate variablesI just do this: function process_user_input($value) { return mysql_real_escape_string(strip_tags(trim($value))); // Or whatever processing you need } $_SAFE_GET = array_map('process_user_input', $_GET); $_SAFE_POST = array_map('process_user_input', $_POST); That way you never need to take them out of an array in the first place. Then you can do things like: mysql_query("INSERT INTO table (col) VALUES ('{$_SAFE_POST['val']}')"); Jasper