HTML:
<input type="checkbox" name="product[book]" value="10" /> book
<input type="checkbox" name="product[plane]" value="20" /> plane
PHP:
foreach ($_POST['product'] as $name => $value) {
echo $value;
}
How to get the total (sum) value if the user select two fields (book & plane)
In your form you have an array of product. If you foreach that, create a $total = 0; at the start, add the value to it, at the end you have a total.
You can check that would work by
print_r($_POST)and you’ll see any selected values show as part of an array within the array of $_POST.