title: Why won't this php code work and how do I code a confirmation that both emails are the same?
body: <p>I'm trying to make a form for a website I'm building. I'm very new to coding but I <em>have</em> done some simple websites before and have a very basic knowledge of web coding. I have two issues. 1) I'm trying to code this form so that if the two email fields do not match, a message will show up in some way notifying the viewer. 2) The send button will send the info in an email but two parts aren't working: the check box array isn't working (it only says "array" and I want it to say the values separated by commas), and I don't know how to have it redirect to a separate success page (i.e. contact_success.html). Giving me the answer alone is fine, but it would be really great if you can tell me why you use the specific codes.</p>
  
  <p><strong>Here is the HTML code for the entire form:</strong></p>
  
  <pre><code>&lt;form name="contact" action="contactProcess.php" method="post" onSubmit="return validateForm()"&gt;
  &lt;table  width="100%" cellspacing="6"&gt;
      &lt;tr&gt;
          &lt;th width="30%" class="th_contact"&gt;*Name:&lt;/th&gt;
          &lt;td width="70%"&gt;&lt;input type="text" size="50" name="name"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
         &lt;th class="th_contact"&gt;*Your email  address:&lt;/th&gt;
         &lt;td&gt;&lt;input type="text" size="50" name="email"&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
         &lt;th class="th_contact"&gt;*Confirm email  address:&lt;/th&gt;
         &lt;td&gt;&lt;input type="text" size="50" name="email2"&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
         &lt;th class="th_contact"&gt;How did you hear about us?&lt;/th&gt;
         &lt;td&gt;&lt;input type="radio" name="referral" value="friend or family"&gt;Friend or Family&lt;br /&gt;
         &lt;input type="radio" name="referral" value="veterinarian"&gt;Veterinarian&lt;br /&gt;
         &lt;input type="radio" name="referral" value="flyer or mailer"&gt;Flyer or Mailer&lt;br /&gt;
         &lt;input type="radio" name="referral" value="humane society or similar facility"&gt;Humane     Society or Similar Facility&lt;br /&gt;
         &lt;input type="radio" name="referral" value="walked or drove by"&gt;Walked or Drove By&lt;br /&gt;
         &lt;input type="radio" name="referral" value="other"&gt;Other&lt;br /&gt;
         &lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
         &lt;th valign="top"&gt;&lt;h5&gt;What type of pet do you have?&lt;/h5&gt;&lt;/th&gt;
         &lt;td&gt;&lt;input type="checkbox" name="pet[]" value="dog"&gt;Dog&lt;br /&gt;
         &lt;input type="checkbox" name="pet[]" value="cat"&gt;Cat&lt;br /&gt;
         &lt;input type="checkbox" name="pet[]" value="bird"&gt;Bird&lt;br /&gt;
         &lt;input type="checkbox" name="pet[]" value="fish"&gt;Fish&lt;br /&gt;
         &lt;input type="checkbox" name="pet[]" value="reptile"&gt;Reptile&lt;br /&gt;
         &lt;input type="checkbox" name="pet[]" value="small animal"&gt;Small Animal&lt;br /&gt;
         &lt;/td&gt;
     &lt;/tr&gt;
         &lt;td  align="left"&gt;&lt;input type="submit"  class="button" value="submit"&gt;
         *Required  Fields&lt;/td&gt;
     &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Here's the PHP:</strong></p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
       &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
       &lt;title&gt;Contact PHP&lt;/title&gt;
       &lt;link href="A4P.css" rel="stylesheet" type="text/css" /&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;?php {
  //Set up message body
  $message = "Form Submitted on: " . date("m/d/y") . "\n";
  $message .= "\n";
  $message .= "Name: " . $_POST['name'] . "\n";
  $message .= "Email Address: " . $_POST['email'] . "\n\n";
  $message .= "Referred by: " . stripslashes($_POST['referral']) . "\n";
  $message .= "Pets: " . $_POST['pet'];
  
  
  //Set up email
  $to = "example@example.com, &lt;" . $_POST['email'] . "&gt;";
  $subject = "New Email Club Entry";
  $headers = "From: " . "All 4 Pets Website";
  
  //Send email
  mail($to,$subject,$message,$headers);
  
  }
  ?&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Here's how the email looks in case it matters:</strong></p>
  
  <p>Form Submitted on: 11/18/13 <br /> <br />
  Name: Brad Moore <br />
  Email Address: 123@yahoo.com <br /> <br />
  Referred by: walked or drove by <br />
  Pets: Array</p>