Shakeel Posted March 6, 2013 Share Posted March 6, 2013 I have 4 checkbox, 4 text field and 1 text area in my form and i need to send this information to my email i am getting only text field and text area information not checkbox value can anyone help me on this below is the code in HTML <input name="checkbox" type="checkbox" id="checkbox" value="I AM INTERESTED IN BEING A DISTRIBUTOR"> <input name="checkbox" type="checkbox" id="checkbox" value="I OWN A FLEET OF COMMERCIAL VEHICLES"> <input name="checkbox" type="checkbox" id="checkbox" value="I NEED A LOCAL SUPPLIER FOR MYGREENOIL"> <input name="checkbox" type="checkbox" id="checkbox" value="I HAVE A TECHNICAL QUESTION"> <input type="text" name="name" id="name"> <input type="text" name="address" id="address"> <input type="text" name="phonenumber" id="phonenumber"> <input type="text" name="emailaddress" id="emailaddress"> <textarea name="commentsorquestion" id="commentsorquestion" cols="45" rows="5"></textarea> in php <?php $name = $_POST['name']; $address = $_POST['address']; $phonenumber = $_POST['phonenumber']; $emailaddress = $_POST['emailaddress']; $InquiryFor = $_POST['inquiryfor']; $commentsorquestion = $_POST['commentsorquestion']; $checkbox = $_POST['checkbox']; foreach($_POST['checkbox'] as $value) { echo 'Checked: '.$value.' '; } $email_from = 'mymail@mydomain.com'; $email_subject = "From website inquiry form"; $email_body = "$checkbox \n\nContact Person:\t$name \n\nAddress:\t$address \nPhone Number:\t$phonenumber \nEmail Address:\t$emailaddress \nComments or Questions:\t$commentsorquestion\n\n\n". $to = "mymail@mydomain.com"; //Send the email! mail($to,$email_subject,$email_body); //done. redirect to thank-you page. header('Location: index.htm'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/275301-need-help-checkbox-to-php-mail/ Share on other sites More sharing options...
abrahamgarcia27 Posted March 6, 2013 Share Posted March 6, 2013 I believe you are missing the name on the input field for checkbox <input name="checkbox" type="checkbox" id="checkbox" name ="checkbox" value="I AM INTERESTED IN BEING A DISTRIBUTOR"> Quote Link to comment https://forums.phpfreaks.com/topic/275301-need-help-checkbox-to-php-mail/#findComment-1416878 Share on other sites More sharing options...
abrahamgarcia27 Posted March 6, 2013 Share Posted March 6, 2013 Nevermind i just saw it Quote Link to comment https://forums.phpfreaks.com/topic/275301-need-help-checkbox-to-php-mail/#findComment-1416879 Share on other sites More sharing options...
abrahamgarcia27 Posted March 6, 2013 Share Posted March 6, 2013 Use this instead <form action="exec.php" method="post"> <input name="checkbox[]" type="checkbox" id="checkbox" value="I AM INTERESTED IN BEING A DISTRIBUTOR"> <input name="checkbox[]" type="checkbox" id="checkbox" value="I OWN A FLEET OF COMMERCIAL VEHICLES"> <input name="checkbox[]" type="checkbox" id="checkbox" value="I NEED A LOCAL SUPPLIER FOR MYGREENOIL"> <input name="checkbox[]" type="checkbox" id="checkbox" value="I HAVE A TECHNICAL QUESTION"> <input type="submit" value="submit" /> Quote Link to comment https://forums.phpfreaks.com/topic/275301-need-help-checkbox-to-php-mail/#findComment-1416880 Share on other sites More sharing options...
Shakeel Posted March 6, 2013 Author Share Posted March 6, 2013 Thanks but not working Quote Link to comment https://forums.phpfreaks.com/topic/275301-need-help-checkbox-to-php-mail/#findComment-1416881 Share on other sites More sharing options...
abrahamgarcia27 Posted March 6, 2013 Share Posted March 6, 2013 (edited) It should work did you put the for loop inside the body of the email, so it sends every checked value in the email? Do not look the whole body though Edited March 6, 2013 by abrahamgarcia27 Quote Link to comment https://forums.phpfreaks.com/topic/275301-need-help-checkbox-to-php-mail/#findComment-1416887 Share on other sites More sharing options...
gmaestroo Posted March 6, 2013 Share Posted March 6, 2013 Use this instead <form action="exec.php" method="post"> <input name="checkbox[]" type="checkbox" id="checkbox" value="I AM INTERESTED IN BEING A DISTRIBUTOR"> <input name="checkbox[]" type="checkbox" id="checkbox" value="I OWN A FLEET OF COMMERCIAL VEHICLES"> <input name="checkbox[]" type="checkbox" id="checkbox" value="I NEED A LOCAL SUPPLIER FOR MYGREENOIL"> <input name="checkbox[]" type="checkbox" id="checkbox" value="I HAVE A TECHNICAL QUESTION"> <input type="submit" value="submit" /> @Shakeel This will return an array with true or false, not a single value. So maybe this is why it won't work Quote Link to comment https://forums.phpfreaks.com/topic/275301-need-help-checkbox-to-php-mail/#findComment-1416888 Share on other sites More sharing options...
abrahamgarcia27 Posted March 6, 2013 Share Posted March 6, 2013 Thats not what i get check it out http://sunerandgarcia.com/phpfreaks/checkbox.html Quote Link to comment https://forums.phpfreaks.com/topic/275301-need-help-checkbox-to-php-mail/#findComment-1416889 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.