Gabriel_Haukness Posted July 27, 2008 Share Posted July 27, 2008 Hi, I am trying to take extract the selected checkboxes from 2 arrays and place into a message e-mail. I have omitted the junk and am just giving the good stuff: <form action="feedback2.php" method="post"> <?php //Declare issue checkbox array $issue_array = array ( "Wrinkles", "Fine lines", "Crows feet", "Lines between eyebrows", "Lines and folds on your face", "Hollow cheeks", "Thin lips", "Brown spots", "Rosacea", "Broken capillaries", "Large pores", "Spider veins", "Uneven skin texture", "Acne scars", "Unwanted hair on face", "Unwanted hair on body", "Sagging skin on face and neck", "Sagging skin on body", "Cellulite", "Inches you wish to reduce", "After-baby loose skin", "Acne prone skin", "Dull skin", ); //style issue array print "<p class=\"margins, indent\">"; //print issue array using a foreach loop foreach($issue_array as $issue ) print "<input type=\"checkbox\" name=\"issue_box[]\" value=\"$issue\">$issue<br />"; //Declare procedure checkbox array $procedure_array = array ( " Laser Genesis Skin Rejuvenation", "Laser Hair Removal", "IPL/LimeLight™ Sun and Age Spot Treatment", "Facial and Leg Veins Treatment", "Titan™ Skin Tightening", "Pearl Skin Resurfacing", "Tattoo Removal", "Body Contouring", "Cellulite Treatment", "Circumferential Reduction", "Botox®", "Dermal Fillers", "Vitalize Peel®", "Massage and Reflexology", "Waxing", ); //print procedure array using a foreach loop foreach($procedure_array as $procedure ) print "<input type=\"checkbox\" name=\"procedure_box[]\" value=\"$procedure\">$procedure<br />"; ?> <!--BEGIN feedback.php --> $issue_box = $_POST['issue_box']; $procedure_box = $_POST['procedure_box']; if ($issue_box != NULL){ foreach($_POST as $issue) if(is_array($issue)){ //print "True<br />"; $issue_array= implode ( ', ', $issue)."\n\n" ; print $issue_array; } } if ($procedure_box != NULL){ foreach($_POST as $procedure) if(is_array($procedure)){ //print "True<br />"; $procedure_array= implode ( ', ', $procedure)."\n\n"; print $procedure_array; } } This code takes the last procedure chunk and overwrites the issue chunk. Thus in the message contents the procedures get placed in the issue section and duplicated in the procedure section. Anythoughts on why this is being overwritten? Any help would be great as I am baffled at this point. mod edit: code tags added Link to comment https://forums.phpfreaks.com/topic/116856-solved-multiple-checkbox-arrays-return-only-last-array-values/ Share on other sites More sharing options...
Barand Posted July 27, 2008 Share Posted July 27, 2008 use if (isset($_POST['procedure_box'])) { $procedure_array = join(', ', $_POST['procedure_box']); } and similar for other array Link to comment https://forums.phpfreaks.com/topic/116856-solved-multiple-checkbox-arrays-return-only-last-array-values/#findComment-600964 Share on other sites More sharing options...
Gabriel_Haukness Posted July 27, 2008 Author Share Posted July 27, 2008 Thanks Barand, works like a charm! Link to comment https://forums.phpfreaks.com/topic/116856-solved-multiple-checkbox-arrays-return-only-last-array-values/#findComment-601007 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.