Hi. I have created an HTML form that includes a few checkbox groups that I would like the visitors to be able to check all values that apply to them. I have searched online and have tried figuring out a way to have multiple values handled and emailed to my account. I do not know that much about PHP so can someone PLEASE help me. Thanks so much in advance.
Here is what I have so far:
(HTML form)
(PHP Code)Code:<form action="volunteer-form2.php" method="post"> <table width="595" class="style8"> <tr> <td colspan="3">Your Interested In Volunteering For: (check all that apply)</td> </tr> <tr> <td width="177" height="30"><input type="checkbox" name="interested[]" value="Home Repairs" /> Home Repairs</td> <td width="177"><input type="checkbox" name="interested[]" value="Yard Maintenance" /> Yard Maintenance</td> <td width="219"><input type="checkbox" name="interested[]" value="Gardening" /> Gardening</td> </tr> <tr> <td height="30"><input type="checkbox" name="interested[]" value="Fund Raising" /> Fund Raising</td> <td><input type="checkbox" name="interested[]" value="Special Events" /> Special Events</td> <td><input type="checkbox" name="interested[]" value="Public Relations" /> Public Relations</td> </tr> <tr> <td height="30"><input type="checkbox" name="interested[]" value="Driving" /> Driving</td> <td><input type="checkbox" name="interested[]" value="Mentoring Children" /> Mentoring Children</td> <td><input type="checkbox" name="interested[]" value="Special Programs For Families" /> Special Programs For Families</td> </tr> <tr> <td height="30" colspan="3"><input type="checkbox" name="interested[]" value="Organizing Supplies" /> Organizing Supplies In Our Warehouse Facilities</td> </tr> <tr> <td height="10" colspan="3"> </td> </tr> </table> <input type="submit" name="submit" value="Submit" /> </form>
Code:<?php $to = "myemail@hotmail.com" ; $from = $_REQUEST['email'] ; $name = $_REQUEST['firstname'] ; $headers = "From: $from"; $subject = "Web Inquiry"; $fields = array(); $fields{"firstname"} = "Name"; $fields{"lastname"} = "Last Name"; $fields{"street"} = "Address"; $fields{"city"} = "City"; $fields{"state"} = "State"; $fields{"zip"} = "Zip"; $fields{"phone"} = "Phone Number"; $fields{"email"} = "Email Address"; $fields{"contactpreference"} = "Contact Preference"; $fields{"contacttime"} = "Best Time To Contact"; $fields{"email"} = "Email Address"; $fields{"learn"} = "Learned About The Program"; $fields{"interested"} = "Interested In"; $fields{"available"} = "Available"; $fields{"medicalconditions"} = "Medical Conditions"; $fields{"emergencycontact"} = "Emergency Contact"; $fields{"contactphone"} = "Emerency Contact Phone"; $fields{"contactemail"} = "Emergency Contact Email"; $fields{"comments"} = "Question or Comment"; $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } $headers2 = "From: noreply@mysitename.com"; $subject2 = "Thank you for contacting us"; $autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible. If you have any more questions, please visit our website at www.mysitename.com"; if($from == '') {print "You have not entered an email, please go back and try again";} else { $send = mail($to, $subject, $body, $headers); $send2 = mail($from, $subject2, $autoreply, $headers2); if($send) {header( "Location: thankyou.html" );} else {print "We encountered an error sending your mail, please notify our webmaster at myemail@hotmail.com"; } }} ?>



Reply With Quote

Bookmarks