txhoyt Posted February 11, 2010 Share Posted February 11, 2010 I'm simply using a php to submit a very simple form via email. Everything is working fine except that I can't get the form to submit multiple check boxes with the same name. It keeps sending only the last check box in the list that is selected. I've stripped out just one of the form check box elements so you can get a sense of what I'm talking about Form code: <form id="form_info_request" name="form_info_request" method="post" action="/php/contactjst.php"> <label for="information">What design service are you interested in?</label> <br /> <span class="form_text"> <input name="information" type="checkbox" class="boxes" tabindex="11" value="Funeral Home Design" /> Funeral Home Design<br /> <input name="information" type="checkbox" class="boxes" tabindex="12" value="Interior Design" /> Interior Design<br /> <input name="information" type="checkbox" class="boxes" tabindex="13" value="Mausoleum Design" /> Mausoleum Design<br /> <input name="information" type="checkbox" class="boxes" tabindex="14" value="Cemetery Planning" /> Cemetery Planning<br /> <input name="information" type="checkbox" class="boxes" tabindex="15" value="Visualization Services" /> Visualization Services<br /> <input name="information" type="checkbox" class="boxes" tabindex="16" value="Other Services" /> Other Services</span><br /> <input name="other_services" type="text" class="form_left_margin" id="other_services" tabindex="17" /> <br /><br /> <input name="submitbutton" type="submit" id="submitbutton" value="Submit" tabindex="31" /> <input name="resetbutton" type="reset" id="resetbutton" value="reset" tabindex="32" /> </form> PHP I'm using: <?php $to = "myemail@me.com"; $from = $_REQUEST['email'] ; $name = $_REQUEST['name'] ; $headers = "from: $from"; $subject = "Website Information Request Submission"; $fields = array(); $fields{"name"} = "Name"; $fields{"company"} = "Company"; $fields{"title"} = "Title"; $fields{"email"} = "Email Address"; $fields{"phone"} = "Phone Number"; $fields{"web"} = "Web Address"; $fields{"street"} = "Street Address"; $fields{"city"} = "City"; $fields{"state"} = "State"; $fields{"zipcode"} = "Zipecode"; $fields{"information"} = "More information"; $fields{"develop"} = "Develop a"; $fields{"find_us"} = "Found JST via"; $fields{"comments"} = "Additional Comments"; $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } $headers2 = "From: info@me.comm"; $subject2 = "Thank you for contacting us"; $autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.me.com. Please do not reply to this message."; if($name == '') {print "You have not entered a name, please go back and try again";} else { 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: http://www.me.com" );} else {print "We encountered an error sending your mail, please notify info@me.com"; } } } ?> Any help you can give me I would greatly appreciate. Quote Link to comment https://forums.phpfreaks.com/topic/191805-im-a-newbie-so-be-gentle/ Share on other sites More sharing options...
abazoskib Posted February 11, 2010 Share Posted February 11, 2010 you need to use DOM or Xpath to access the td elements of the table. Quote Link to comment https://forums.phpfreaks.com/topic/191805-im-a-newbie-so-be-gentle/#findComment-1010931 Share on other sites More sharing options...
sader Posted February 11, 2010 Share Posted February 11, 2010 specify ckeckbox names in html like information[] <= see extra [] ? then in php u will have array of information <?php $len = count($_POST['information']); for($i=0; $i<$len; $i++) { echo $_POST['information'][$i]; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/191805-im-a-newbie-so-be-gentle/#findComment-1010938 Share on other sites More sharing options...
taquitosensei Posted February 11, 2010 Share Posted February 11, 2010 try this <input name="information[]" type="checkbox" class="boxes" tabindex="14" value="Cemetery Planning" /> Cemetery Planning<br /> then foreach($POST['information'] as $information) { } Quote Link to comment https://forums.phpfreaks.com/topic/191805-im-a-newbie-so-be-gentle/#findComment-1010942 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.