Dear All,
can you please help me sort out something re POSTing data from a checkbox form.
Sending page is:
$my_array = array('dog', 'cat', 'horse', 'badger');
echo "<form method=\"post\" action=\"arrayreceive.php\" name=\"myForm\">";
foreach ($my_array as $animal) {
echo "<input type=\"checkbox\" name=\"selectedanimals[]\" value=\"".$animal."\">$animal<br>";
}
echo "<input type=\"submit\" value=\"submit\">";
echo "</form>";
Receiving page is:
if ($_POST['selectedanimals[]']) {
echo "something was received <br>";
} else {
echo "nothing was received <br>";
}
$selected_animals[] = $_POST['selectedanimals[]'];
foreach ($selected_animals as $animal) {
echo "From the POSTed array ----- $animal<br>";
}
The POSTed data is never received, and I cannot figure out why. (Using PHP5, with Register_globals off – I think it worked when they were on, I don't have control of register_globals).
Can anyone please suggest how I can get this to work.
Thanks in advance.