title: PHP DD/MM/YYYY Validation
body: <p>apologies for probably a simple question, but i am new to PHP and Javascript.</p>
  
  <p>I am creating a login validation in PHP that requires a registering user to input their date of birth in a DD/MM/YYYY Format, that returns an error message if the date is entered in any other format. I am unsure how to do this, other than using preg_match, however this doesnt seem to work...</p>
  
  <p>variables:</p>
  
  <pre><code>$DOB = $_POST['DOB'];
  $error_message = '';
  </code></pre>
  
  <p>The Date Validation Segment</p>
  
  <pre><code>elseif (!preg_match("/^(0?[1-9]|[12][0-9]|3[01])\/\.- \/\.- \d{2}$/", $DOB))
  {
    $error_message = 'Invalid Date';
  }
  </code></pre>
  
  <p>Error Display</p>
  
  <pre><code>  if ($error_message != '')
    {
      echo 'Error: '.$error_message.' &lt;a href="javascript: history.back();"&gt;Go Back&lt;/a&gt;.';
      echo '&lt;/body&gt; &lt;/html&gt;';
      exit;
    }
    else
    {
     echo'&lt;p&gt;&lt;strong&gt;Form Submitted Successfully!&lt;/strong&gt;&lt;/p&gt;';
    }
  </code></pre>
  
  <p>This is not a duplicate, i tried other threads and none of their solutions worked.</p>