I have a form that sends all the data with jQuery .serialize()
In the form are four arrays qty[], etc
it send the form data to a sendMail page and I want to get the posted data back out of the arrays.
I have tried:
JavaScript
x
$qty = $_POST['qty[]'];
foreach($qty as $value)
{
$qtyOut = $value . "<br>";
}
And tried this:
JavaScript
for($q=0;$q<=$qty;$q++)
{
$qtyOut = $q . "<br>";
}
Is this the correct approach?
Advertisement
Answer
You have []
within your $_POST
variable – these aren’t required. You should use:
$qty = $_POST['qty'];
Your code would then be:
JavaScript
$qty = $_POST['qty'];
foreach($qty as $value) {
$qtyOut = $value . "<br>";
}