Page 1 of 1

Checking date of birth

Posted: Tue Jun 19, 2007 6:10 am
by aceconcepts
Hi,

How would i check if some one is older than 16 years of age?

I have a "new user" form which allows people to create a user account. I want to be able to make sure that anyone who is creating a user account is 16 years or older.

Thanks.

Posted: Tue Jun 19, 2007 6:21 am
by superdezign

Re: Checking date of birth

Posted: Tue Jun 19, 2007 6:22 am
by ghadacr
Can we see some code, so we can make some suggestions???

Posted: Tue Jun 19, 2007 6:24 am
by Gente
Hmm... I recall there was a function is_user_already_16(...) but I don't remeber the arguments. :)
If seriously, just ask him about it or ask his birthday. There are no other ways at this moment.
If you want - ask him to solve little equation for example.

Posted: Wed Jun 20, 2007 3:25 am
by mikeeeeeeey
Hi there, just tried to think up a solution for myself, but its actually quite hard!

Here's some code I've just had a quick blast through, the number it outputs ($num), may look like a random number but the first 2 digits represent the user's age.

Its far from finished, but it's here if you want to use it as a starting point.

Code: Select all

$user_birth = (int)$_POST['yyyy'] . $_POST['mm'] . $_POST['dd'];
  $date       = (int)date("omd");
  $sum        = ($date - $user_birth);
  
  if(isset($_POST['submit'])){
	echo "User is " . $sum . " years old";
  }
Hope it helps!