Posting array from form Posting array from form arrays arrays

Posting array from form


Give each input a name in array format:

<input type="hidden" name="data[EstPriceInput]" value="" />

Then the in PHP $_POST['data']; will be an array:

  print_r($_POST);         // print out the whole post  print_r($_POST['data']); // print out only the data array


When you post that data, it is stored as an array in $_POST.

You could optionally do something like:

<input name="arrayname[item1]"><input name="arrayname[item2]"><input name="arrayname[item3]">

Then:

$item1 = $_POST['arrayname']['item1'];$item2 = $_POST['arrayname']['item2'];$item3 = $_POST['arrayname']['item3'];

But I fail to see the point.


You're already doing that, as a matter of fact. When the form is submitted, the data is passed through a post array ($_POST). Your process.php is receiving that array and redistributing its values as individual variables.