Hi and thanks for reading my question. I am using a simple form to get some input :
<p>Select your favorite two countries below:</p>
<form id="world" name="world" action="/order.php" method="post">
<input type="checkbox" name="countries" value="USA" /> USA<br />
<input type="checkbox" name="countries" value="Canada" /> Canada<br />
<input type="checkbox" name="countries" value="Japan" /> Japan<br />
<input type="checkbox" name="countries" value="China" /> China<br />
<input type="checkbox" name="countries" value="France" /> France<br />
<input type="submit" value="Order">
</form>
I want to make sure order.php is geting all of the choices selected, so order.php only contains the following code :
<pre>
<?php var_dump($_POST);?>
</pre>
Unfortunately, it is only outputting whatevre is the bottom-most checkbox that is checked.
The output is like this :
array(1) { ["countries"]=> string(6) "Canada" }
If i try the following code for output :
<?php
foreach($_POST as $key=>$post_data){
echo "You posted:" . $key . " = " . $post_data . "<br>";
}
?>
I get this output :
You posted:countries = Canada
Can anyone tell me where i am going wrong and how i can retrieve all of the data, for every box that is ticked ?
Thank you.