title: JQuery + PHP contact form multiple checkbox
body: <p>I have a little problem with my contact form. I added multiple checkbox but once proceeded the email only shows 1 when I check all of them.
  I might be missing something.
  Here is my code if anyone can help me.
  Thanks</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;div id="contact_form"&gt;
  &lt;div style="color:#000;" id="contact_results"&gt;&lt;/div&gt;
  &lt;div id="contact_body"&gt;
  &lt;div class="form-group"&gt;
  &lt;input type="text" class="form-control" name="nom" id="nom" placeholder="Nom"&gt;
   &lt;/div&gt;
   &lt;div class="form-group"&gt;
   &lt;input type="text" class="form-control" name="prenom" id="prenom" placeholder="Prenom"&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
  &lt;input type="text" class="form-control" name="annee" id="annee" placeholder="Année de naissance"&gt;
   &lt;/div&gt;
  &lt;div class="form-group"&gt;
  &lt;label&gt;&lt;input type="checkbox" name="id[]" id="id1" value="Habille"&gt;Habillé&lt;/label&gt;
  &lt;label&gt;&lt;input type="checkbox" name="id[]" id="id2" value="Sexy"&gt;Sexy (+18)&lt;/label&gt;
      &lt;label&gt;&lt;input type="checkbox" name="id[]" id="id3" value="Lingerie - Maillot de bain"&gt;Lingerie/Maillot de bain (+18)&lt;/label&gt;
      &lt;label&gt;&lt;input type="checkbox" name="id[]" id="id4" value="Nue cache"&gt;Nue caché (+18)&lt;/label&gt;
      &lt;label&gt;&lt;input type="checkbox" name="id[]" id="id5" value="Nue non cache"&gt;Nue non caché (+18)&lt;/label&gt;
   &lt;/div&gt;
   &lt;div class="form-group"&gt;
   &lt;input type="text" class="form-control" name="ville" id="ville" placeholder="ville"&gt;
   &lt;/div&gt;
   &lt;div class="form-group"&gt;
    &lt;input type="email" class="form-control" name="email" id="email" placeholder="Email"&gt;
   &lt;/div&gt;
   &lt;div class="form-group"&gt;
   &lt;textarea class="form-control" rows="3" name="message" id="message" placeholder="Votre message"&gt;&lt;/textarea&gt;
   &lt;/div&gt;
  &lt;button type="submit" id="submit_btn" class="btn btn-primary btn-xl page-scroll"&gt;Envoyer&lt;/button&gt;
   &lt;/div&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>JQuery</p>
  
  <pre><code>    $(document).ready(function() {
  $("#submit_btn").click(function() {     
  var proceed = true;
  $("#contact_form input[required=true], #contact_form textarea[required=true]").each(function(){
  $(this).css('border-color',''); 
  if(!$.trim($(this).val())){ //if this field is empty 
  $(this).css('border-color','red'); //change border color to red   
  proceed = false; //set do not proceed flag
  }
  var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; 
  if($(this).attr("type")=="email" &amp;&amp; !email_reg.test($.trim($(this).val()))){
  $(this).css('border-color','red'); //change border color to red   
  proceed = false; //set do not proceed flag              
  }   
  });
  if(proceed) //everything looks good! proceed...
  {
  post_data = {
  'user_nom'      : $('input[name=nom]').val(),
  'user_prenom'   : $('input[name=prenom').val(),
  'user_message'      : $('textarea[name=message]').val(),
  'user_ville'    : $('input[name=ville]').val(),
  'user_email'    : $('input[name=email]').val(),
  'user_theme' : $("input[name='id[]']:checked").val(),
  'user_annee'    : $('input[name=annee]').val(),
          };
  $.post('modelc.php', post_data, function(response){  
  if(response.type == 'error'){ //load json data from server and output message     
  output = '&lt;div class="error"&gt;'+response.text+'&lt;/div&gt;';
  }else{
  output = '&lt;div class="success"&gt;'+response.text+'&lt;/div&gt;';
  //reset values in all input fields
  $("#contact_form  input[required=true], #contact_form textarea[required=true]").val(''); 
  $("#contact_form #contact_body").slideUp(); //hide form after success
  }
  $("#contact_form #contact_results").hide().html(output).slideDown();
  }, 'json');
  }
  });
  $("#contact_form  input[required=true], #contact_form textarea[required=true]").keyup(function() { 
  $(this).css('border-color',''); 
  $("#result").slideUp();
  });
  });
  </code></pre>
  
  <p>PHP</p>
  
  <pre><code>    &lt;?php
  header('Access-Control-Allow-Origin: *');
  header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
  $headers = 'From: '.$user_email.'' . "\r\n";
  $headers .= 'Reply-To: '.$user_email.'' . "\r\n";
  $headers .= 'X-Mailer: PHP/' . phpversion();
  $headers .= "MIME-Version: 1.0\r\n";
  $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
  if($_POST)
  {
  $to_email       = "hello@originsphotography.eu"; //Recipient email, Replace with own email here
  
  //check if its an ajax request, exit if not
  if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
  
      $output = json_encode(array( //create JSON data
          'type'=&gt;'Erreur', 
          'text' =&gt; 'Sorry Request must be Ajax POST'
      ));
      die($output); //exit script outputting json data
  } 
  
  //Sanitize input data using PHP filter_var().
  $user_nom       = filter_var($_POST["user_nom"], FILTER_SANITIZE_STRING);
  $user_prenom    = filter_var($_POST["user_prenom"], FILTER_SANITIZE_STRING);
  $user_message      = filter_var($_POST["user_message"], FILTER_SANITIZE_STRING);
  $user_ville      = filter_var($_POST["user_ville"], FILTER_SANITIZE_STRING);
  $user_email     = filter_var($_POST["user_email"], FILTER_SANITIZE_EMAIL);
  $user_annee    = filter_var($_POST["user_annee"], FILTER_SANITIZE_EMAIL);
  $user_theme    = $_POST["user_theme"];
  $subject        = "Contact site internet";
  $from           = "www.originsphotography.eu";
  
  //additional php validation
  if(strlen($user_nom)&lt;4){ // If length is less than 4 it will output JSON error.
      $output = json_encode(array('type'=&gt;'error', 'text' =&gt; 'Le champ est trop court ou vide'));
      die($output);
  }
  if(!filter_var($user_email, FILTER_VALIDATE_EMAIL)){ //email validation
      $output = json_encode(array('type'=&gt;'error', 'text' =&gt; 'Veuillez entrer une adresse email valide'));
      die($output);
  }
  
  //email body
  $message_body = "Nom : ".$user_nom."\r\n\r\nPrénom : ".$user_prenom."\r\n\r\nEmail : ".$user_email."\r\n\r\nMessage : ".$user_message."\r\n\r\nVille : ".$user_ville."\r\n\r\nTheme : ".$user_theme."\r\n\r\nAnnee : ".$user_annee ;
  
  //proceed with PHP email.
  $headers = 'From: '.$user_email.'' . "\r\n" .
  'Reply-To: '.$user_email.'' . "\r\n" .
  'X-Mailer: PHP/' . phpversion();
  
  $send_mail = mail($to_email, $subject, $message_body, $headers);
  
  if(!$send_mail)
  {
      //If mail couldn't be sent output error. Check your PHP email configuration (if it ever happens)
      $output = json_encode(array('type'=&gt;'error', 'text' =&gt; 'Could not send mail! Please check your PHP mail configuration.'));
      die($output);
  }else{
      $output = json_encode(array('type'=&gt;'message', 'text' =&gt; 'Merci, '.$user_prenom .' pour votre message. Je vous réponds très vite !'));
      die($output);
  }
  }
  ?&gt;
  </code></pre>