title: How to send through multiple checkbox values to an email via PHP
body: <p>Below shows an extract of my HTML file. The forms objective was when a user selects a checkbox it would add a further value onto a starting total value. </p>
  
  <pre><code>&lt;!doctype html&gt;  
  
   &lt;html  class=""&gt;  
    &lt;head&gt;
  
    &lt;script type="text/javascript"&gt;
      function checkTotal() {
          document.listForm.total.value = '';
          var sum = 68.50;
          for (i=0;i&lt;document.listForm.choice.length;i++) {
            if (document.listForm.choice[i].checked) {
              sum = sum + parseFloat(document.listForm.choice[i].value);
            }
          }
          document.listForm.total.value = sum.toFixed(2);
      }
  &lt;/script&gt;
  
    &lt;/head&gt;
  
    &lt;body&gt;
  
  
     &lt;form name="listForm" method="post" action="standard_form.php"&gt;
  
    &lt;div class="form-group"&gt;
     &lt;label for="additional_extras"&gt;Extras&lt;/label&gt;&lt;br&gt;&lt;br&gt;
  &lt;input type="checkbox" name="choice" value="60.00" onchange="checkTotal()"&gt; Number1 &lt;/div&gt;
  
    &lt;div class="form-group"&gt;
     &lt;label for="additional_extras_2"&gt;&lt;/label&gt;&lt;br&gt;
  &lt;input type="checkbox" name="choice" value="20.00" onchange="checkTotal()"&gt; Number 2
  &lt;/div&gt;
  
   &lt;div class="form-group"&gt;
     &lt;label for="additional_extras_3"&gt;&lt;/label&gt;&lt;br&gt;
  &lt;input type="checkbox" name="choice" value="45.00" onchange="checkTotal()"&gt; Number 3
  &lt;/div&gt;
  
   &lt;div class="form-group"&gt;
     &lt;label for="additional_extras_4"&gt;&lt;/label&gt;&lt;br&gt;
  &lt;input type="checkbox" name="choice" value="23.50" onchange="checkTotal()"&gt; Number 4
  &lt;/div&gt;
  
  &lt;div class="form-group"&gt;
     &lt;label for="additional_extras_5"&gt;&lt;/label&gt;&lt;br&gt;
  &lt;input type="checkbox" name="choice" value="40.00" onchange="checkTotal()"&gt; Number 5
  &lt;/div&gt;
  
  &lt;div class="form-group"&gt;
     &lt;label for="additional_extras_6"&gt;&lt;/label&gt;&lt;br&gt;
  &lt;input type="checkbox" name="choice" value="23.50" onchange="checkTotal()"&gt; Number 6
  &lt;/div&gt;
  
  &lt;div class="form-group"&gt;
     &lt;label for="additional_extras_7"&gt;&lt;/label&gt;&lt;br&gt;
  &lt;input type="checkbox" name="choice" value="120.00" onchange="checkTotal()"&gt; Number 7
  
  &lt;br&gt;
    &lt;h3&gt;Your Current Package Total: £&lt;input type="text" readonly placeholder="68.50"  name="total" id="total"/&gt;&lt;/h3&gt;
  
    &lt;button type="submit" class="btn btn-default"&gt;Submit&lt;/button&gt;  
  
  &lt;/form&gt;   
  
       &lt;/div&gt;
  
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I would then send this form to the following php file which would then email the forms outputs. I have managed to get all other fields to send successfully but cannot get the check box values to send and be outputted by email without the adding function (which makes the total) becoming interrupted. </p>
  
  <pre><code>&lt;?php
  if(isset($_POST['email'])) {
  
      // EDIT THE 2 LINES BELOW AS REQUIRED
      $email_to = "myemail";
      $email_subject = "mysubject";
  
      function died($error) {
          // your error code can go here
          echo "We are very sorry, but there were error(s) found with the form you submitted. ";
          echo "These errors appear below.&lt;br /&gt;&lt;br /&gt;";
          echo $error."&lt;br /&gt;&lt;br /&gt;";
          echo "Please go back and fix these errors.&lt;br /&gt;&lt;br /&gt;";
          die();
      }
  
          $choice = $_POST['choice']; // required
          $total = $_POST['total']; // required
  
      $email_message = "Form details below.\n\n";
  
      function clean_string($string) {
        $bad = array("content-type","bcc:","to:","cc:","href");
        return str_replace($bad,"",$string);
      }
  
      $email_message .= "Choice: ".clean_string($choice)."\n";
      $email_message .= "Order Total: ".clean_string($total)."\n";
  
  
  // create email headers
  $headers = 'From: '.$email_from."\r\n".
  'Reply-To: '.$email."\r\n" .
  'X-Mailer: PHP/' . phpversion();
  @mail($email_to, $email_subject, $email_message, $headers);  
  ?&gt;
  
  &lt;!-- include your own success html here --&gt;
  
  Thank you for contacting us. We will be in touch with you very soon.
  
  &lt;?php
  }
  ?&gt;
  </code></pre>
  
  <p>Please does anyone have a solution for this?? What ever I try I just cant get the check boxes to send through there values and display themselves in the email like the rest of the form.</p>
  
  <p>Any help would be much appreciated!</p>
  
  <p>Thanks!</p>