Re: input processor function

From: Date: Wed, 10 Jan 2001 19:50:07 +0000
Subject: Re: input processor function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-33753@lists.php.net to get a copy of this message
This is how I usually do it: <input type="text" name="f[firstname]"> Then you have an array of values in $f then just do : while(list($key,$val) = each($f)) { $$key = strip_tags($val); } Which will then create a variable $firstname and put a strip_tags of $val into it (leaving your original $f array intact for future use) --Joe On Wed, Jan 10, 2001 at 02:45:55PM -0500, Jon Rosenberg wrote: > I want to process information submitted by a form, but I want to clean up > the info before I use it. I have about 40 form fields, of several field > types. If I only had a few form fields, I would do ths manually, but since > I have so many my code will be much neater to do it with a function. I want > to loop through all the POST vars and do a strip_tags() and trim() on each > one. > > Is this how I should be doing this? The code below works how I want it to. > However, I would prefer, for performance/memory issues to not perform this > on unneeded fields, such as radio buttons and select boxes where the > information is already formatted how I want. Is there any way to only > perform this on text boxes and textarea fields? THanks! > > foreach ( $HTTP_POST_VARS as $key=>$value ) > { > $value=strip_tags($value); > $value=trim($value); > // for debugging use only print all the variables from web form > print "$key = $value<br />"; > } > > ----------------------------------------------------------------- > Jonathan Rosenberg > Be fierce, be fabulous, change the world! > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net --- Joe Stump PHP Programmer www.Care2.com

« previous php.general (#33753) next »