Processing HTML forms

From: Date: Tue, 03 Dec 2002 23:16:05 +0000
Subject: Processing HTML forms
Groups: php.db 
Request: Send a blank email to php-db+get-23787@lists.php.net to get a copy of this message
I have a form handler that I use that I wrote. It works great, but I have a problem. I want it to save all the values from the forms when used with PHP. For example, I have a text box that is named "data[phone][1][number]" and I want the form to be automatically filled in for me. It works for the first [] (ie data[stuff] gets filled in properly in my code). Here's the code: function displayText($name, $default = '', $size = HTML_FORM_TEXT_SIZE, $maxlength = '') { if (preg_match("/^(.*)\[+(.*)\]+$/",$name,$x)) $setvalue = $GLOBALS[$x[1]][$x[2]]; else $setvalue = $GLOBALS[$name]; $default = stripslashes((empty($setvalue))?$default:$setvalue); if (!$maxlength) { print "<input name=\"$name\" value=\"$default\" size=\"$size\""; } else { print "<input name=\"$name\" value=\"$default\" size=\"$size\" maxlength=\"$maxlength\""; } print " />"; } How would I write this to support multiple brackets? Basically it is the preg_match line that does the "magic." Peter --------------------------------------------------------------------------- Peter Beckman Internet Guy beckman@purplecow.com http://www.purplecow.com/ ---------------------------------------------------------------------------

« previous php.db (#23787) next »