subCutaneas Posted November 9, 2012 Share Posted November 9, 2012 Hi. So I have an online form that's pretty extensive. I'm having no issues with dropdowns, radios, text fields and single checkboxes, but a have a large list of options (checkboxes) for clients to check: <input type="checkbox" name="i_have[]" value="value1" />value1<br /> <input type="checkbox" name="i_have[]" value="value2" />value2<br /> <input type="checkbox" name="i_have[]" value="value3" />value3<br /> <input type="checkbox" name="i_have[]" value="value4" />value4<br /> <input type="checkbox" name="i_have[]" value="value5" />value5<br /> <input type="checkbox" name="i_have[]" value="value6" />value6<br /> ...and so on As you can see, I want this to be an array. I want it emailed to me - everything else emails fine, but this is proving a real problem. PHP side, I have tried: print_r($_POST['i_have']); with: Present Issues & Prior Illnesses: $i_haveField As the responder. All this does is posts the checked options on the "thanks for signing" page after the client hits the SUBMIT button, but it doesn't send anything in the email. I have also tried: if (isset($_POST['i_have'])) { $i_haveField = $_POST['i_have']; } This is one step closer, printing "ARRAY" in the appropriate area in the email responder, with nothing printed on the "thanks for signing" page, but no checked options are included in the email. Where am I going wrong?! I know it's something simple, but as a PHP newbie, I just can't see it. Please could you offer assistance. Quote Link to comment https://forums.phpfreaks.com/topic/270487-php-array-emailing-issues/ Share on other sites More sharing options...
DavidAM Posted November 9, 2012 Share Posted November 9, 2012 Checkboxes are only POSTed if they are actually checked. Since you have it as an array, you can get a list of the values from checked checkboxes using implode: if (isset($_POST['i_have'])) $i_haveField = implode(', ', $_POST['i_have']); else $i_haveField = ''; Quote Link to comment https://forums.phpfreaks.com/topic/270487-php-array-emailing-issues/#findComment-1391223 Share on other sites More sharing options...
subCutaneas Posted November 9, 2012 Author Share Posted November 9, 2012 I wish I had ovaries and a uterus because, DavidAM, I want your babies! You have just helped end literally WEEKS of frustration and anguish! I love you. Quote Link to comment https://forums.phpfreaks.com/topic/270487-php-array-emailing-issues/#findComment-1391225 Share on other sites More sharing options...
JamesThePanda Posted November 9, 2012 Share Posted November 9, 2012 also instead of print_r try var_dump Thats should give you more information and remember to use <pre> tags Quote Link to comment https://forums.phpfreaks.com/topic/270487-php-array-emailing-issues/#findComment-1391226 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.