$datestamp = date("j.n.Y", mktime());
$t_arr = explode("." , $datestamp);
$current_day = $t_arr[0];
$current_month = $t_arr[1];
$current_year = $t_arr[2];
$year_dif = $current_year - $birth_year;
if(($birth_month > $current_month) || ($birth_month == $current_month && $current_day < $birth_day))
{
$age = $year_dif - 1;
}
else
{
$age = $year_dif;
}
if($age < 18)
{
header("Location: under_18.php");
}
else
{
header("Location: 18_and_over.php");
}
There is what I use, it can probably be optimized, just change the header locations to whatever pages you want displayed and put your DOB values in these variables:
$birth_year = "1987";
$birth_month = "08";
$birth_day = "30";
Obviously the values of the variables means the user is 18 and should go to the 18_and_over page.
hope this helps.