title: Radio Buttons with PHP Form Handling
body: <p>I have a basic form that I am submitting using some basic PHP. I have the form submission working great, except that I have a radio button (for preferred method of contact) and I am not sure how to add that in the PHP so that sends in the email. Both radio button options have the same name, so that isn't working as the value. My code is below.</p>
  
  <p>The PHP is as follows:</p>
  
  <pre><code>&lt;?php
    $name    = stripslashes($_POST['name']);
    $email   = stripslashes($_POST['email']);
    $phone   = stripslashes($_POST['phone']);
    $contact = stripslashes($_POST['contact']);
    $message = stripslashes($_POST['message']);
    $form_message = "Name: $name \nEmail: $email \nPhone: $phone \nPreferred Method of Contact: $contact \nMessage: $message";
  
  // Exit process if field "human" is filled (because this means it is spam)
  if ( $_POST['human'] ) {
    echo 'Tastes Like Spam!'; exit; }
  // if it is not filled, submit form
  else {
    header( "Location: http://www.newurl.com");
  
    mail("myemail@gmail.com", "Email Subject", $form_message, "From: $email" );
  }
  ?&gt;
  </code></pre>
  
  <p>The HTML for the form is below:</p>
  
  <pre><code>  &lt;form method="post" id="form" action="handle_form.php"&gt;
      &lt;div class="field"&gt;
        &lt;input type="text" name="human" id="human" class="txt" /&gt;
      &lt;/div&gt;
      &lt;div class="field form-inline"&gt;
        &lt;label class="contact-info" for="txtName"&gt;Name*&lt;/label&gt;
        &lt;input type="text" name="name" id="name" class="txt" value=""/&gt;
      &lt;/div&gt;
      &lt;div class="field form-inline"&gt;
        &lt;label class="contact-info" for="txtEmail"&gt;Email*&lt;/label&gt;
        &lt;input type="text" name="email" id="email" class="txt" value=""/&gt;
      &lt;/div&gt;
      &lt;div class="field form-inline"&gt;
        &lt;label class="contact-info" for="txtPhone"&gt;Phone&lt;/label&gt;
        &lt;input type="text" name="phone" id="phone" class="txt" value=""/&gt;
      &lt;/div&gt;
      &lt;div class="field form-inline radio"&gt;
        &lt;label class="radio" for="txtContact"&gt;Preferred Method of Contact&lt;/label&gt;
        &lt;input class="radio" type="radio" name="contact" checked /&gt; &lt;span&gt;Email&lt;/span&gt;
        &lt;input class="radio" type="radio" name="contact" /&gt; &lt;span&gt;Phone&lt;/span&gt;
      &lt;/div&gt;
      &lt;div class="field form-inline"&gt;
        &lt;textarea rows="10" cols="20" name="message" id="message" class="txt" value=""&gt;&lt;/textarea&gt;
      &lt;/div&gt;
      &lt;div class="submit"&gt;
        &lt;input class="submit" type="submit" name="submit" value="Submit Form"&gt;
      &lt;/div&gt;
    &lt;/form&gt;
  </code></pre>
  
  <p>Thanks so much for the help!</p>