I'm trying to parse an HTML checkbox question into various booleans for each option.
The form is getting passed via POST. The question needs to be required in the final version, but I currently am not enforcing that. I need the variable for each question to be initialized at the end for the create function call that follows.
I first tried parsing each checkbox seperately.
```<div><input type="checkbox" id="socialevents" name="socialevents"><label for="socialevents"> Social Events</label> </div>```
and then
```if($args['socialevents']){ $socialevents=1;}else{ $socialevents=0;}```
This did not work. All the variables get set to 0
I've tried making the results into an array and then iterating over the array
```input type="checkbox" id="gascards" name="services[]" name="gascards"><label for="gascards"> Gas Cards</label>```
and then
```$services=$args['services'];if(empty($services)){ $gascards=0; ....}else{ $n=count($services); echo $n . "number of services[] items"; for($i=0;$i<$n;$i++){ switch ($services[$i]){ case 'gascards': $gascards=1; ......}```
This appears to result in the unchecked items getting set to 1.I have also tried switching on the full php variable "$gascards" which also did not work.
I also tried looking directly into the POST array. This results in errors of variables that were not initialized.
if(isset($_POST['gascards'])){ $gascards=1; } else{ $gascards=0; }
How do I processes the checkbox question?