title: Validate php form fail
body: <p>This code works fine in seperated file named form.php, but when i paste it to 
  wordpress theme page it does not even validate form and not even send mail of course. Why is there no any action after i clikced submit button in wordpress theme?
  Anyone can help me to solve problem?</p>
  
  <pre><code>  get_header();
  
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  
      $nameError = $mailError = $messageError = '';
  
      function validate($data){
          if(empty($data)){
              return false;
          }else{
              $data = trim($data);
              $data = stripslashes($data);
              $data = htmlspecialchars($data);
              return $data;
          }
      }
  
    //Validate name input
      if(!validate($_POST['name'])){
        $nameError = 'Polje ime je obavezno.';
      }else{
          if (!preg_match("/^[a-zA-Z ]*$/",$_POST['name'])) {
              $nameError = "Polje moze sadrzavati samo slova i razmak"; 
          }
      }
  
   //Validate email input
      if(!validate($_POST['email'])){
          $mailError = 'Polje email je obavezno';
      }else{
          if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
              $mailError = "Nevazeća email adresa"; 
           }
      }
  
   //Validate message textarea
      if(!validate($_POST['message'])){
          $messageError = 'Molimo unesite poruku';
      }
  
   if(empty($nameError) &amp;&amp; empty($mailError) &amp;&amp; empty($messageError)){
          //Create the body
          $body = "Ime: {$_POST['name']}\n\nPoruka: {$_POST['message']}";
  
          //Make it no longer than 70 characters long 
          $body = wordwrap($body, 70);
  
          //Send the mail
          mail('example@example.com', 'Contact Form Submission', 
       $body, 
      "From: {$_POST['email']}");
  
          //Print a message 
          echo '&lt;p&gt;&lt;em&gt;Thank you for contacting me. I will reply some day. 
       &lt;/em&gt;&lt;/p&gt;';
        }else{
          echo '&lt;p style="font-weight: bold; color: #C00"&gt;Please fill out 
   the 
       form completley.&lt;/p&gt;';
        }   
    }
  </code></pre>
  
  <p><strong>HTML</strong> Code that is placed in same file as php validation</p>
  
  <pre><code>        &lt;section class="contact-img"&gt;
      &lt;div class="container-fluid"&gt;
          &lt;div class="row"&gt;
           &lt;?php the_post_thumbnail(); ?&gt;
          &lt;/div&gt;
        &lt;/div&gt;
    &lt;/section&gt;
  
   &lt;section class="contact"&gt;
    &lt;div class="container"&gt;
      &lt;div class="row"&gt;
          &lt;?php dynamic_sidebar('contact-page'); ?&gt;  
              &lt;div class="col-md-12"&gt;
                  &lt;h4 class="col-xs-12 text-center"&gt;&lt;strong&gt;Ostavite 
    poruku&lt;/strong&gt;&lt;/h4&gt;     
              &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="container"&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-xs-10 col-xs-offset-1 col-sm-6 col-sm-offset-3"&gt;
  
              &lt;form method="POST" action="&lt;?php echo 
  htmlspecialchars($_SERVER["PHP_SELF"]);?&gt;"&gt;
  
                  &lt;div class="form-group"&gt;
                      &lt;input type="text" class="form-control" name="name"  
  value="" placeholder="Ime"&gt;
                      &lt;div&gt;&lt;?php if(isset($nameError)) echo $nameError; ?&gt; 
   &lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;div class="form-group"&gt;
                      &lt;input type="text" class="form-control" name="email" 
   value="" placeholder="E-mail"&gt;
                      &lt;div&gt;&lt;span class="error"&gt;&lt;?php if(isset($mailError)) 
   echo $mailError; ?&gt;&lt;/span&gt;&lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;div class="form-group"&gt;
                      &lt;textarea class="form-control" name="message" rows="3" 
    placeholder="Poruka"&gt;&lt;/textarea&gt;
                      &lt;div&gt;&lt;span class="error"&gt;&lt;?php 
    if(isset($messageError)) echo $messageError; ?&gt;&lt;/span&gt;&lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;input class="btn btn-default" type="button" name="button" 
    value="Pošalji"&gt;
              &lt;/form&gt;
  
          &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
   &lt;/section&gt;
  </code></pre>