Skip to content Skip to sidebar Skip to footer

How To Fetch The Get/post Elements In A Form Without Knowing The Name Of The Controls Inside The Form

I had the list of items. When the user clicks a item, a div is generated with a textbox So user can select multiple

Solution 1:

You can use a for-each loop:

foreach ($_GETas$get_key => $get_value)

Solution 2:

You could use a foreach loop on $_POST like Matthew suggested or you could set the names of the inputs as an array

for example

<input type="text" name="foo[]">

foreach ($_POST['foo'] as$key => $value) {
    ...
}

The data would look like something like this

[foo] => Array
     (
         [0] => ...
         [1] => ...
         [2] => ...
         [3] => ...
     )

Post a Comment for "How To Fetch The Get/post Elements In A Form Without Knowing The Name Of The Controls Inside The Form"