php birthday validation function
<p>I am trying to add a birthday validation function in my php script to make sure users are 18+. But I am stuck on how to add it in my if statement.</p>

<p>This is what is taken from the input fields:</p>

<pre><code>$ydob = ($_POST['ydob']);
$mdob =($_POST['mdob']);
$ddob = ($_POST['ddob']);
$dob = $ddob."-".$mdob."-".$ydob;
</code></pre>

<hr>

<p>The function:</p>

<pre><code>function validateDOB($dob){

list($ydob,$mdob,$ddob) = explode("-",$dob);
$year_diff = date("Y") - $ydob;
$month_diff = date("m") - $mdob;
$day_diff = date("d") - $ddob;

if ($day_diff &lt; 0 || $month_diff &lt; 0) {
$year_diff--;
return $year_diff;
} }
</code></pre>

<hr>

<p>This block is to check if all details are entered correctly. <strong>So my question is how would I add the function here to validate if the user is over 18.</strong></p>

<pre><code>if((!$username) || (!$country) || (!$dob) || (!$email) || (!$password)){

    $error_message = "You did not submit the following required information!&lt;br /&gt;&lt;br /&gt;";
    if(!$username){
        $error_message .= "Enter a User Name";
    } else if(!$country){
        $error_message .= "Enter a Country"; 
    } else if(!$dob){ 
                    $error_message .= "Enter a D.O.B";
            } else if(!$email){ 
                    $error_message .= "Enter a Email Address"; 
            } else if(!$password){ 
                $error_message .= "Enter a Password"; 
            }
     } else {
        ....}
</code></pre>

<p>Thank you so much.
Ray</p>
