SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jul 2000
    Location
    Odense - Denmark
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi!

    How do I (re)submit formdata from at multiple select statement?
    When pressing "submit" the first time I get the data as an array in PHP, but how do I resubmit it in another form?
    (like you can resubmit data with a "hidden" field, but how does it work when there is multiple data?)

    Thanks in advance.

  2. #2
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    madsen,

    Simply create several hidden form fields with the array as their NAME's. The following form, for example, will pass an array variable named $multi containing two values, "test1" and "test2":

    <FORM ACTION=... METHOD=POST>
    <INPUT TYPE=HIDDEN NAME="multi[]" VALUE="test1">
    <INPUT TYPE=HIDDEN NAME="multi[]" VALUE="test2">
    <INPUT TYPE=SUBMIT NAME="submit">
    </FORM>


    To create such a form in PHP:

    <FORM ACTION=... METHOD=POST>
    <?
    for ($i=0;$i<count($multi);$i++) {
    echo("<INPUT TYPE=HIDDEN NAME=\"multi[]\" VALUE=\"".addslashes($multi[$i])."\">");
    }
    ?>
    <INPUT TYPE=SUBMIT NAME="submit">
    </FORM>


    Easy, huh?

    ------------------
    -Kevin Yank.
    http://www.SitePoint.com/
    Helping Small Business Grow Online!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •