Search Webmaster Help and Solution

Age Check!!!

I have an form that a user will fill in.
It is then sent to this page.
The user enters ther Date of Birth in a selection of drop down lists. One for Day,Month and Year.
On this page i want it to stop the user from registering if their age is under 13 or over 19...

This code SHOULD work, because ive used it before... but for some reason, it AINT...

PHP Code: <?php
$DOB = $yyyy-$mm-$dd;
$currentdate = date(Y-m-d);
?>
<?php

$ages = explode(- ,$DOB);
if (!checkdate($ages[1],$ages[2],$ages[0])) return ; 
$pMonth = $ages[1]; 
$pDay = $ages[2]; 
$pYear = $ages[0]; 

$agess = explode(- ,$currentdate);
if (!checkdate($agess[1],$agess[2],$agess[0])) return ; 
$qMonth = $agess[1]; 
$qDay = $agess[2]; 
$qYear = $agess[0]; 

$age = $qYear - $pYear - ((($qMonth < $pMonth) || ($qMonth == $pMonth && $qDay < $pDay)) ? 1 : 0);
$maxAge = 19;
$minAge = 13;

    if (($age > $maxAge) AND ($age == $minAge))
    {
        print <html>;
        print <head><title>Invailid Age!</title></head>;
        print <body>;
        print <b>You cannot register because you are not the right age!</b><br>;
        print You have to be 13-19 years old to join.;
        print <p><u><strong>Sorry!</strong></u></p>;
        print </body>;
        print </html>;
    } else {
?>

<!--
Rest of page
-->
<? } ?>

PLEASE HELP ME! I have an form that a user will fill in.
It is then sent to this page.
The user enters ther Date of Birth in a selection of drop down lists. One for Day,Month and Year.
On this page i want it to stop the user from registering if their age is under 13 or over 19...

This code SHOULD work, because ive used it before... but for some reason, it AINT...

PHP Code: <?php
$DOB = $yyyy-$mm-$dd;
$currentdate = date(Y-m-d);
?>
<?php

$ages = explode(- ,$DOB);
if (!checkdate($ages[1],$ages[2],$ages[0])) return ; 
$pMonth = $ages[1]; 
$pDay = $ages[2]; 
$pYear = $ages[0]; 

$agess = explode(- ,$currentdate);
if (!checkdate($agess[1],$agess[2],$agess[0])) return ; 
$qMonth = $agess[1]; 
$qDay = $agess[2]; 
$qYear = $agess[0]; 

$age = $qYear - $pYear - ((($qMonth < $pMonth) || ($qMonth == $pMonth && $qDay < $pDay)) ? 1 : 0);
$maxAge = 19;
$minAge = 13;

    if (($age > $maxAge) AND ($age == $minAge))
    {
        print <html>;
        print <head><title>Invailid Age!</title></head>;
        print <body>;
        print <b>You cannot register because you are not the right age!</b><br>;
        print You have to be 13-19 years old to join.;
        print <p><u><strong>Sorry!</strong></u></p>;
        print </body>;
        print </html>;
    } else {
?>

<!--
Rest of page
-->
<? } ?>

PLEASE HELP ME!

View Complete Thread with Replies

Related Items

Query failed: connection to localhost:3354 failed (errno=111, msg=Connection refused).