I have a form as below which allows users to add more input field through a addmore button . my question is how can i retrieve the array in POST and echo them out . as you can see i have two input fields with name product[] and quantity[] (more fields can be added) . i have to get the value of the field using a a foreach loop and store it in a varibla $message to be used in mail(). i have tried a for each loop for both and my for each loop code as below
$product = $_POST['product'];
$quantity = $_POST['quantity'];
foreach($product as $value)
{
$message = "<html><head>
<title></title>
</head>
<body>
<table>
<tr>
<td>".$value."";
}
foreach($quantity as $value)
{
$message.=" </td>
<td>".$value."</td>
</tr>
</table>
</body>
</html>";
}
My input form
<form id="quick_post" method="post">
<table id="input_fields">
<tr>
<td><input class="orderinput" type="text" name="product[]" /></td>
<td><input class="orderquan" type="text" name="quantity[]" size="1" maxlength="3" /></td>
</tr>
</tr>
</table>
<input class="more" type="button" value="Addmore" name="addmore" /> // a jquery script is processed on click to add more fields.
<input class="send" type="submit" value="Send" name="send" /></form>
the output for this is i get only the first row of products printed and for the remaining row only the quantity is printed or echoed. as below
Product Name Quantity
aaaaaa 22
33