Processing HTML forms

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/
---------------------------------------------------------------------------


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux