beevbo Posted April 1, 2009 Share Posted April 1, 2009 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. Link to comment https://forums.phpfreaks.com/topic/152148-solved-getting-a-checkbox-array-to-process-to-page/ Share on other sites More sharing options...
JD* Posted April 1, 2009 Share Posted April 1, 2009 It looks like there is a space in your call to the $_POST variable. Make sure $_POST[ 'service_required'] is $_POST['service_required'] Link to comment https://forums.phpfreaks.com/topic/152148-solved-getting-a-checkbox-array-to-process-to-page/#findComment-799063 Share on other sites More sharing options...
beevbo Posted April 2, 2009 Author Share Posted April 2, 2009 I does look like that, but there isn't a space there. Link to comment https://forums.phpfreaks.com/topic/152148-solved-getting-a-checkbox-array-to-process-to-page/#findComment-799129 Share on other sites More sharing options...
beevbo Posted April 2, 2009 Author Share Posted April 2, 2009 I solved it, missed the $key=='service_required', had it as 'extras'. Sorry to trouble you. Link to comment https://forums.phpfreaks.com/topic/152148-solved-getting-a-checkbox-array-to-process-to-page/#findComment-799148 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.