Aloha!
I have foreach() to parse each checkbox value a user selects separately. It worked fine before I used it in an IF expression-but now it's not. Without the IF, if the user doesn't select any checkbox and DOES submit the form, the foreach won't recognize any data (obviously) and will return w/an error. Below is the code of the page:
Thanks!PHP Code:<?php
$a = $_GET['a'];
if($a == 'a') {
$state = $_POST['state'];
if(!$state) {
echo "<font color=red>Please select a state</font>";
} else {
foreach ($state as $statename);
{
echo "$statename is checked";
}
}
}
?>
<form action="test.php?a=a" method="post">
<input type="checkbox" value="New York" name="state[]">New York<br />
<input type="checkbox" value="Maryland" name="state[]">Maryland<br />
<input type="submit">
</form>



Reply With Quote

Bookmarks