I have various checkbox values which I want to pass to an XML page, but I can't work out how to do it. I feel like I'm close and I've been searching all through the forums but can't find the answer I need. Here's the relevant code:
<form action="<?php MyFunction(); ?>" method="post">
4. Road proposals by private bodies: <input type="checkbox" name="box[0]" /><br />
5. Public paths or byways: <input type="checkbox" name="box[1]" /><br />
6. Advertisements: <input type="checkbox" name="box[2]" /><br />
7. Completion Notices: <input type="checkbox" name="box[3]" /><br />
8. Parks and countryside: <input type="checkbox" name="box[4]" /><br />
9. Pipelines: <input type="checkbox" name="box[5]" /><br />
10. Houses in multiple occupation: <input type="checkbox" name="box[6]" /><br />
11. Noise Abatement: <input type="checkbox" name="box[7]" /><br />
12. Urban development Areas: <input type="checkbox" name="box[8]" /><br />
13. Enterprise Zones: <input type="checkbox" name="box[9]" /><br />
14. Inner urban improvement areas: <input type="checkbox" name="box[10]" /><br />
15. Simplified planning zones: <input type="checkbox" name="box[11]" /><br />
16. Land maintenance notices: <input type="checkbox" name="box[12]" /><br />
17. Mineral consultation areas: <input type="checkbox" name="box[13]" /><br />
18. Hazardous substance consents: <input type="checkbox" name="box[14]" /><br />
19. Environmental and pollution notices: <input type="checkbox" name="box[15]" /><br />
20. Food safety notices: <input type="checkbox" name="box[16]" /><br />
21. Hedgerow notices: <input type="checkbox" name="box[17]" /><br /><br />
<input type="submit" value="Submit">
</form>
<?php
function MyFunction() {
global $box, $searches, $environment;
$box = array("<option4 />","<option5 />","<option6 />","<option7 />","<option8 />","<option9 />","<option10 />","<option11 />","<option12 />","<option13 />","<option14 />","<option15 />","<option16 />","<option17 />","<option18 />","<option19 />","<option20 />","<option21 />");
foreach ( $box as $box2 )
{
if ($_POST['box2']) { $boxtest = "$box2" ; }
}
$datenow = date( "d-m-y" );
$timenow = date( "H:i" );
$f = fopen ("secondtest.inc", "aw");
fwrite ($f, "$boxtest\n");
fclose ($f);
}
?>
I could do each checkbox with a separate value, but I heard arrays were easier!