lewerjason Posted August 4, 2011 Report Share Posted August 4, 2011 Dear Members, I have a form with few fields and checkbox, I want to get the check box values in email. I just get CareerFocus - Array as value in the email. <td width="324" bgcolor="E9E9D4" valign="top"> <input type="checkbox" name="Question1[]" value="Marketing"> Marketing<br> <input type="checkbox" name="Question1[]" value="Contact"> Contact<br> <input type="checkbox" name="Question1[]" value="Intelligence"> Intelligence<br> <input type="checkbox" name="Question1[]" value="Leadership"> Leadership<br> <input type="checkbox" name="Question1[]" value="Product"> Development</td> <td width="330" bgcolor="E9E9D4" valign="top"> <input type="checkbox" name="Question2[]" value="Marketing"> Devices<br> <input type="checkbox" name="Question2[]" value="Sales"> Excellence<br> <input type="checkbox" name="Question2[]" value="Sales & Marketing"> Adherence<br> </td> if(isset($_POST['submit'])) { $CareerFocus = $_POST['Question1']; $IndustryFocus = $_POST['Question2']; } if(empty($errors)) { //send the email $to = $your_email; $subject="New form submission"; $from = $your_email; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $body = "A user $firstname submitted the contact form:\n". "CareerFocus: $CareerFocus\n". "IndustryFocus: $IndustryFocus\n". //"IP: $ip\n"; $headers = "From: $from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; mail($to, $subject, $body,$headers); header('Location: thank-you.html'); } can anyone help with this Quote Link to comment Share on other sites More sharing options...
falkencreative Posted August 4, 2011 Report Share Posted August 4, 2011 This has a pretty clear explanation of working with checkboxes. Take a look at the section of code under the "Check Box Group" header: http://www.html-form-guide.com/php-form/php-form-checkbox.html Basically, rather than simply doing $CareerFocus = $_POST['Question1']; you need to use an array to loop through the results. 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.
Note: Your post will require moderator approval before it will be visible.