title: Submit button returns to index page instead of sending data
body: <p>Here is the link for the website - <a href="http://zigzagadvertising.com.ph/aleemguiapal/page/2/" rel="nofollow">http://zigzagadvertising.com.ph/aleemguiapal/page/2/</a></p>
  
  <p>I have a problem regarding my forms in wordpress. Whenever i click on the submit button it returns to the index page instead of sending the data into an email address </p>
  
  <p><strong>This is my PHP code which i placed on top of the Header.php. This code is placed before the  tag</strong></p>
  
  <pre><code>&lt;?php 
  $error=false;
  $sent=false;
  if(isset($_POST['submit'])) {
  if(empty($_POST['firstname']) || empty($_POST['email']) || empty($_POST['message'])) {
  $error = true;
  } else {
  
   $to = "clestcruz@gmail.com";
  
   $name = trim($_POST['firstname']);
   $email = trim($_POST['email']);
   $comments = trim($_POST['message']);
  
   $subject = "Contact Form";
  
   $messages = "Name: $firstname \r\n Email: $email \r\n Comments: $message";
   $headers = "From:" . $name;
   $mailsent = mail($to, $subject, $messages, $headers);
  
   if($mailsent){
       $sent= true;
  }
  }
  }
  ?&gt;
  </code></pre>
  
  <p><strong>And this is my custom page(Contact Page)</strong></p>
  
  
  
  
  
  <pre><code>&lt;!--CONTACT--&gt;
  &lt;div  class="container"&gt;
  &lt;div  class="eleven columns contact"&gt;
       &lt;div id="contact-container" class="eleven columns alpha omega contact"&gt;
           &lt;h2&gt;contact us&lt;/h2&gt;
           &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras non lacus vel nulla molestie cursus quis a urna. Donec sodales venenatis consequat. Sed tristique elit nec diam rhoncus adipiscing&lt;/p&gt;
       &lt;/div&gt;
  
       &lt;div id="note-container" class="eleven columns alpha omega note"&gt;
           &lt;p&gt;All fields marked with an asterisk(&lt;span class="asterisk"&gt;*&lt;/span&gt;) are required&lt;/p&gt;
       &lt;/div&gt;
  
       &lt;div class="contactform"&gt;
       &lt;form id="register-form" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="post"&gt;
  
  
       &lt;?php if($error == true) { ?&gt;
       &lt;p class="error"&gt; There are some misisng fields.&lt;/p&gt;
       &lt;?php } if($sent == true) { ?&gt;
       &lt;p class="sent"&gt;Thank you for sending your message&lt;/p&gt;&lt;?php } ?&gt;
  
  
           &lt;div class="four columns alpha contact-form"&gt;
  
           &lt;label&gt;prefix&lt;/label&gt;
           &lt;input type="text"  /&gt;
           &lt;label&gt;&lt;span class="asterisk"&gt;*&lt;/span&gt;first name&lt;/label&gt;
           &lt;input type="text" name="firstname"/&gt;
           &lt;label&gt;&lt;span class="asterisk"&gt;&lt;/span&gt;middle name&lt;/label&gt;
           &lt;input type="text" name="middlename"/&gt;
           &lt;label&gt;&lt;span class="asterisk"&gt;&lt;/span&gt;last name&lt;/label&gt;
           &lt;input type="text" name="lastname"/&gt;
           &lt;label&gt;&lt;span class="asterisk"&gt;*&lt;/span&gt;email address&lt;/label&gt;
           &lt;input type="text" name="email"/&gt;
  
          &lt;/div&gt;
  
          &lt;div class="four columns contact-form"&gt;
  
           &lt;label&gt;phone&lt;/label&gt;
           &lt;input type="text" /&gt;
           &lt;label&gt;street&lt;/label&gt;
           &lt;input type="text" /&gt;
           &lt;label&gt;&lt;span class="asterisk"&gt;&lt;/span&gt;zip&lt;/label&gt;
           &lt;input type="text" name="zip" /&gt;
           &lt;label&gt;&lt;span class="asterisk"&gt;&lt;/span&gt;city&lt;/label&gt;
           &lt;input type="text" name="city" /&gt;
  
  
          &lt;/div&gt;
  
          &lt;div class="clearfix"&gt;&lt;/div&gt;
  
          &lt;div class="eleven columns contact-form alpha omega"&gt;
  
          &lt;label&gt;&lt;span class="asterisk"&gt;&lt;/span&gt;subject&lt;/label&gt;
          &lt;input type="text" name="subject"/&gt;
          &lt;label&gt;&lt;span class="asterisk"&gt;*&lt;/span&gt;message&lt;/label&gt;
          &lt;textarea name="message"&gt;&lt;/textarea&gt;
  
  
          &lt;input class="contact-button" type="submit" name="submit" value="submit" /&gt;
          &lt;input class="contact-button" type="reset" value="reset" /&gt;
  
          &lt;/div&gt;
  
       &lt;/form&gt;
       &lt;/div&gt;
  
  &lt;div class="four columns"&gt;
  &lt;/div&gt;
  
  &lt;/div&gt;
  
  
  
   &lt;?php get_sidebar(); ?&gt;
  &lt;/div&gt;   
  
  
  &lt;?php get_footer(); ?&gt;
  
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I tried making a contact page and uploaded it into a free hosting site and it seem to be working properly. I even got the data or values in the forms. Not sure if the reason why my forms is not working properly is because of wordpress itself.</p>