pass each 'name' value form inputs into dynamically created variables

Samepypehat

New Member
I was making a form that is um... quite large and all inputs consist of the form looking like\[code\]<input type="text" id="first_name" name="first_name" />\[/code\]so instead of having to do\[code\]$first_name = $_POST['first_name'];\[/code\]and so on for every input, is there a way to grab every 'name' or 'id' from each input within the \[code\]<form></form>\[/code\] and apply to a variable of the same value of the 'name' or 'id'.I was thinking of something like a \[code\]foreach\[/code\] statement??Any ideas?EDIT:Given this little snippet of code here, how can it be use to now use the example given below?\[code\]function filter($data) { $data = http://stackoverflow.com/questions/3733652/trim(htmlentities(strip_tags($data))); if (get_magic_quotes_gpc()) $data = stripslashes($data); $data = mysql_real_escape_string($data); return $data;}foreach($_POST as $key => $value) { $data[$key] = filter($value); echo $value .'<br />';}\[/code\]
 
Back
Top