dmschenk Posted November 8, 2007 Share Posted November 8, 2007 I am trying to build a form that changes the email addresses depending on the checkboxes that are checked. I am at a total loss getting multiple checkboxes to populate the email variable. I'm not sure if the checkboxes need differing names or the same name. I get an error that says checkboxes with the same name needs to be in brackets[]. With different names I can't get anything to work. Can someone please point me in the right direction? Thanks Dave Quote Link to comment Share on other sites More sharing options...
obsidian Posted November 8, 2007 Share Posted November 8, 2007 I'm not sure what you're needing to do, but here is the basic principle to passing multiple values through one variable: <?php if (isset($_POST['selections'])) { $out = implode(', ' $_POST['selections']); // Treat it as an array echo "You have chosen: $out"; } echo "<form name='my_form' action='' method='post'>\n"; for ($i = 1; $i <= 10; $i++) { echo "<input type='checkbox' name='selections[]' value='$i' /> $i<br />\n"; } echo "<input type='submit' name='submit' value='Choose!' /> echo "</form>\n"; ?> Hope this helps. Quote Link to comment Share on other sites More sharing options...
dmschenk Posted November 8, 2007 Author Share Posted November 8, 2007 Thanks for the quick reply. I'll give this a try tonight to see if I can get it to work. The form I'm trying to build is more or less a signup sheet to request info from a list of departments and depending on the box(es) you check it sends an email to that department to notify them you are interested in something. There are 30+ departments in the list and while I'm not sure this is the best or recommended method it was the best I could come up with. Thanks Dave Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.