Checking date of birth

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Checking date of birth

Post 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.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

User avatar
ghadacr
Forum Contributor
Posts: 135
Joined: Fri May 11, 2007 10:44 am

Re: Checking date of birth

Post by ghadacr »

Can we see some code, so we can make some suggestions???
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Post 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.
User avatar
mikeeeeeeey
Forum Contributor
Posts: 130
Joined: Mon Jul 03, 2006 4:17 am
Location: Huddersfield, UK

Post 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!
Post Reply