When a user attempts to register with my site, I need to verify that they are old enough. I am trying to do this using the getdate()
function.
I understand what getdate()
does, but I am struggling to understand how to use it correctly for this purpose.
<?php
$fn = $_POST["fullname"];
$un = $_POST["username"];
$pw = $_POST["password"];
$dob = $_POST["dayofbirth"];
$mob = $_POST["monthofbirth"];
$yob = $_POST["yearofbirth"];
$date = getdate();
if ( $yob =$yob>= $date["year"]-16)
{
echo "Too young to register!";
}
elseif ($yob <=1899)
{
echo "Don't be silly, you are not that old!";
}
else
{
echo "<h1>Thank you for registering with us!</h1>";
echo "<p> You have successfully registered with these details:
<br>Your full name :$fn<br> Username: $un
<br>Date of birth: $dob $mob $yob</p>";
}
?>