Jump to content

[SOLVED] Multiple checkbox arrays return only last array values


Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.