So this is something I probably should have learned a long time ago when working with forms, but I've never had the need till now.
I have a group of checkboxes representing states, such as:
<label><input type="checkbox" name="State[]" value="AR" />Arkansas</label><br />
<label><input type="checkbox" name="State[]" value="CA" />California</label><br />
<label><input type="checkbox" name="State[]" value="CO" />Colorado</label><br />
<label><input type="checkbox" name="State[]" value="CT" />Connecticut</label><br />
<label><input type="checkbox" name="State[]" value="DE" />Delaware</label><br />
<label><input type="checkbox" name="State[]" value="DC" />District of Columbia</label><br />
<label><input type="checkbox" name="State[]" value="FL" />Florida</label><br />
etc...
The problem I am having is accessing the State data after the form is posted. Even though there are several boxes checked, I get an error in PHP when I try to access the $State array, such as:
extract($_POST);
foreach($State as $key=>$value)
{
// blah
}
generates the error Warning: Invalid argument supplied for foreach()
All of the other $_POST data is passing correctly. What the hell am I doing wrong?