title: Get multiple values of checkbox in PHP
body: <p>I need help with this if any can show me, that would be so great and helpful. </p>
  
  <p>I am trying to get more then one value show up through a checkbox, with this information in PHP has been sent to an email. I can get anyone on the selected list work individually when applied</p>
  
  <p>This is my PHP &amp; HTML code, it all works fine, it's just the program will only send one of the selected list, even if I select more then one.</p>
  
  <p><strong>$ch1, $ch2, $ch3, $ch4 ,$ch5</strong></p>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>&lt;?php
  if(isset($_POST['email'])) {
  
      $email_to = "";
      $email_subject = "";
  
  
      function died($error) {
          // Error Code
          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();
      }
  
      // validation expected data exists
      if(!isset($_POST['firstname']) ||
          !isset($_POST['lastname']) ||
          !isset($_POST['checkboxes']) ||
          !isset($_POST['gender']) ||
          !isset($_POST['email']) ||
          !isset($_POST['subject']) ||
          !isset($_POST['telephone']) ||
          !isset($_POST['message'])) {
          died('We are sorry, but there appears to be a problem with the form you submitted.');       
      }
  
      $firstname = $_POST['firstname']; // required
      $lastname = $_POST['lastname']; // required
      $ch1 = 'unchecked'; // required
      $ch2 = 'unchecked'; // required
      $ch3 = 'unchecked'; // required
      $ch4 = 'unchecked'; // required
      $ch5 = 'unchecked'; // required
      $male_status = 'unchecked'; // required
      $female_status = 'unchecked'; // required
      $email_from = $_POST['email']; // required
      $subject = $_POST['subject']; // required
      $telephone = $_POST['telephone']; // required
      $message = $_POST['message']; // required
  
      $error_message = "";
      $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
    if(!preg_match($email_exp,$email_from)) {
      $error_message .= 'The Email Address you entered does not appear to be valid.&lt;br /&gt;';
    }
      $string_exp = "/^[A-Za-z .'-]+$/";
    if(!preg_match($string_exp,$firstname)) {
      $error_message .= 'The First Name you entered does not appear to be valid.&lt;br /&gt;';
    }
    if(!preg_match($string_exp,$lastname)) {
      $error_message .= 'The Last Name you entered does not appear to be valid.&lt;br /&gt;';
    }
    if(!preg_match($string_exp,$subject)) {
      $error_message .= 'The Subject you entered does not appear to be valid.&lt;br /&gt;';
    }
  
    if (isset($_POST['checkboxes'])) {
  
      $selected_checkboxes = $_POST['checkboxes'];
  
      if (isset($_POST['ch1'])) {
          $ch1 = $_POST['checkboxes'];
  
          if ($ch1 == 'googlechrome') {
              $ch1 = 'checked';
          }
      }
  
      if (isset($_POST['ch2'])) {
          $ch2 = $_POST['checkboxes'];
  
          if ($ch2 == 'firefox') {
              $ch2 = 'checked';
          }
      }
  
      if (isset($_POST['ch3'])) {
          $ch3 = $_POST['checkboxes'];
  
          if ($ch3 == 'safari') {
              $ch3 = 'checked';
          }
      }
  
      if (isset($_POST['ch4'])) {
          $ch4 = $_POST['checkboxes'];
  
          if ($ch4 == 'internetexplorer') {
              $ch4 = 'checked';
          }
      }
  
      if (isset($_POST['ch5'])) {
          $ch5 = $_POST['checkboxes'];
  
          if ($ch5 == 'opera') {
              $ch5 = 'checked';
          }
      }
  }
  
    if (isset($_POST['gender'])) {
  
      $selected_radio = $_POST['gender'];
  
          if ($selected_radio == 'male') {
              $male_status = 'checked';
  
          }
          else if ($selected_radio == 'female') {
              $female_status = 'checked';
          }
      }
    if(strlen($message) &lt; 2) {
      $error_message .= 'The Message you entered do not appear to be valid.&lt;br /&gt;';
    }
    if(strlen($error_message) &gt; 0) {
      died($error_message);
    }
      $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 .= "First Name: ".clean_string($firstname)."\n";
      $email_message .= "Last Name: ".clean_string($lastname)."\n";
      $email_message .= "Gender: ".clean_string($selected_radio)."\n";
      $email_message .= "Telephone: ".clean_string($telephone).
  "\n";
      $email_message .= "Email: ".clean_string($email_from).
  "\n";
      $email_message .= "Subject: ".clean_string($subject).
  "\n";
  $email_message .= "Browsers Used: ".clean_string($selected_checkboxes)."\n";
      $email_message .= "Message: ".clean_string($message).
  "\n";
  
  
  // create email headers
  $headers = 'From: '.$email_from."\r\n".
  'Reply-To: '.$email_from."\r\n" .
  'X-Mailer: PHP/' . phpversion();
  @mail($email_to, $email_subject, $email_message, $headers);  
  ?&gt;
  
  Thank you for contacting us. We will be in touch with you very soon.
  
  &lt;?php
  }
  ?&gt;
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;form id="contact" name="contact" action="contact.php" method="post"&gt;
    &lt;p&gt;
      &lt;label for="firstname"&gt;First Name *&lt;br&gt;
      &lt;/label&gt;
      &lt;input  type="text" name="firstname" maxlength="50" size="30" id="firstname" placeholder="First Name" required autofocus&gt;
      &lt;label for="lastname"&gt;&lt;br&gt;
        &lt;br&gt;
        Last Name *&lt;br&gt;
      &lt;/label&gt;
      &lt;input  type="text" name="lastname" maxlength="50" size="30" id="lastname" placeholder="Last Name" required&gt;
      &lt;label for="email"&gt;&lt;br&gt;
        &lt;br&gt;
        Email Address *&lt;br&gt;
      &lt;/label&gt;
      &lt;input  type="text" name="email" maxlength="80" size="30" id="email" placeholder="example@domain.com" required&gt;
      &lt;label for="telephone"&gt;&lt;br&gt;
        &lt;br&gt;
        Telephone &lt;br&gt;
      &lt;/label&gt;
      &lt;input  type="text" name="telephone" maxlength="30" size="30" id="subject" placeholder="Phone Number" required&gt;
      &lt;br&gt;
      &lt;br&gt;
      &lt;label for="subject"&gt;Subject *&lt;/label&gt;
      &lt;br&gt;
    &lt;input type="text" name="subject" maxlength="30" size="30" id="subject" placeholder="Hello" required&gt;
      &lt;br&gt;
      &lt;br&gt;
      &lt;Input type = "Radio" Name ="gender" value= "Male"&gt;Male
    &lt;Input type = "Radio" Name ="gender" value= "Female" &gt;Female
    &lt;br&gt;
    &lt;/p&gt;
    &lt;p&gt;&amp;quot;What browser are you using, to view this website&amp;quot;&lt;br&gt;
      &lt;Input type = "Checkbox" Name ="checkboxes" value="Google Chrome"&gt;Google Chrome
      &lt;Input type = "Checkbox" Name ="checkboxes" value="Firefox"&gt;Firefox
      &lt;Input type = "Checkbox" Name ="checkboxes" value="Safari"&gt;Safari
      &lt;Input type = "Checkbox" Name ="checkboxes" value="Internet Explorer" &gt;Internet Explorer
      &lt;Input type = "Checkbox" Name ="checkboxes" value="Opera" &gt;Opera
      &lt;br&gt;
      &lt;br&gt;
      Message *&lt;br&gt;
      &lt;/label&gt;
      &lt;textarea  name="message" maxlength="1000" cols="90" rows="6" id="message" placeholder="Type message here" required&gt;&lt;/textarea&gt;
      &lt;br&gt;
      &lt;input type="submit" value="Submit"&gt;
    &lt;/p&gt;
  &lt;/form&gt;
  </code></pre>