Jump to content

[SOLVED] Getting a checkbox array to process to page.


beevbo

Recommended Posts

I'm having problems getting checkbox array in my form to process and display in the body of the following page when the user hits submit. Here's my php code:

 

<?php
if (empty($_POST)) {
print "<p>No data was submitted.</p>";
} else {

foreach ($_POST as $key => $value) {
if (get_magic_quotes_gpc()) $value=stripslashes($value);
if ($key=='extras') {

if (is_array($_POST['service_required']) ){
	print "<tr><td><code>$key</code></td><td>";
	foreach ($_POST['service_required'] as $value) {
			print "$value<br />";
			}
			print "</td></tr>";
	} else {
	print "<tr><td><p class=process_text><i>$key</i></p></td><td><p class=process_text>$value</p></td></tr>\n";
	}
} else {

print "<tr><td><p class=process_text><i>$key</i></p></td><td><p class=process_text>$value</p></td></tr>\n";
}
}
}
?>

 

And here is my array code:

 

<label><b>Engineering Services Required? *</b></label><br>
				<input type="checkbox" name="service_required[]" value="Project Management" class="form1"> Project Management <br>
				<input type="checkbox" name="service_required[]" value="Engineering Design - Underground Utilities" class="form1"> Engineering Design - Underground Utilities <br>
				<input type="checkbox" name="service_required[]" value="Engineering Design - Surface Improvements/Roadways" class="form1"> Engineering Design - Surface Improvements/Roadways <br>
				<input type="checkbox" name="service_required[]" value="Engineering Design - Grading" class="form1"> Engineering Design - Grading <br>
				<input type="checkbox" name="service_required[]" value="Construction Survey" class="form1"> Construction Survey <br>
				<input type="checkbox" name="service_required[]" value="Cost Estimation" class="form1"> Cost Estimating <br>
				<input type="checkbox" name="service_required[]" value="Preliminary/Support Services" class="form1"> Preliminary/Support Services <br>
				<input type="checkbox" name="service_required[]" value="Subdivision/Planning Services" class="form1"> Subdivision/Planning Services <br>
				<input type="checkbox" name="service_required[]" value="Construction Management" class="form1"> Construction Management 

 

I should be noted that I am a complete novice when it comes to PHP, less than novice even, so any help would be greatly appreciated.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.