title: send checkbox value in PHP form
body: <p>I have a question regarding a php form. I've added a checkbox to the existing form, but not sure how to add it to the php. I would like it to send "yes" if the visitores checks it, and "no" if he is not.</p>
  
  <pre><code>&lt;form method="POST" name="contactform" action="contact-form-handler.php"&gt; 
  &lt;p&gt;
  &lt;input type="text" name="name" placeholder="name"&gt;
  &lt;/p&gt;
  &lt;p&gt;
  &lt;input type="tel" name="tel" placeholder="phome"&gt; &lt;br&gt;
  &lt;/p&gt;
  &lt;p&gt;
  &lt;input type="text" name="email" placeholder="mail"&gt; &lt;br&gt;
  &lt;/p&gt;
  &lt;p&gt;
  &lt;input type="checkbox" name="newsletter[]" value="newsletter" checked&gt;i want to sign up   for newsletter&lt;br&gt;
  &lt;/p&gt;
  &lt;input type="submit" value="Submit"&gt;&lt;br&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>here is the php code for the form, everything there except the checkbox. i need to know its value when i receive the mail. for example : "Name: John, Email: test@test.com, Tel:12345, Newsletter: Yes"</p>
  
  <pre><code>&lt;?php 
  $errors = '';
  $myemail = 'test@gmail.com';//&lt;-----Put Your email address here.
  if(empty($_POST['name'])  || 
     empty($_POST['email']) || 
     empty($_POST['tel']))
  {
      $errors .= "\n Error: all fields are required";
  }
  
  $name = $_POST['name']; 
  $email_address = $_POST['email']; 
  $message = $_POST['tel']; 
  
  
  if (!preg_match(
  "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", 
  $email_address))
  {
      $errors .= "\n Error: Invalid email address";
  }
  
  if( empty($errors))
  {
      $to = $myemail; 
      $email_subject = "Contact form submission: $name";
      $email_body = "You have received a new message. ".
      " Here are the details:\n Name: $name \n Email: $email_address \n Tel \n $message\n Newsletter \n $newsletter"
  }
      ; 
  
  
      $headers = "From: $myemail\n"; 
      $headers .= "Reply-To: $email_address";
  
      mail($to,$email_subject,$email_body,$headers);
      //redirect to the 'thank you' page
      header('Location: contact-form-thank-you.html');
  } 
  ?&gt;
  &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; 
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Contact form handler&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;!-- This page is displayed only if there is some error --&gt;
  &lt;?php
  echo nl2br($errors);
  ?&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thank you,</p>