Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Date of Birth


Mighty Mike

Recommended Posts

Hi All,

 

What i would like to do is apply an age restriction to the create_account file where nobody under the age of X can create an account.

 

Has anybody done this on their site as yet or have any idea how it would be done.

 

I had a look in the contribs area but could not find anything. I assume it would be similar to what the other checks are doing but would need to work out the current date less x number of years.

 

Any ideas or pointers would be great. :thumbsup:

 

Thanks

 

Mike

Link to comment
Share on other sites

In create_account.php find this code:

    if (ACCOUNT_DOB == 'true') {
     if (checkdate(substr(tep_date_raw($dob), 4, 2), substr(tep_date_raw($dob), 6, 2), substr(tep_date_raw($dob), 0, 4)) == false) {
       $error = true;

       $messageStack->add('create_account', ENTRY_DATE_OF_BIRTH_ERROR);
     }
   }

...change it to this:

    if (ACCOUNT_DOB == 'true') {
     if (checkdate(substr(tep_date_raw($dob), 4, 2), substr(tep_date_raw($dob), 6, 2), substr(tep_date_raw($dob), 0, 4)) == false) {
       $error = true;
       $messageStack->add('create_account', ENTRY_DATE_OF_BIRTH_ERROR);
     }
  // Change the cutoff to whatever number you want
  $age_cutoff = 35;
  $age_cutoff_timestamp = mktime(0, 0, 0, date("m"), date("d"), date("Y")-$age_cutoff);
  $age_timestamp = strtotime($dob);
  $too_young = $age_timestamp > $age_cutoff_timestamp ? true : false;
  if ( $too_young ){
   $error = true;
       $messageStack->add('create_account', 'You must be '.$age_cutoff.' years old to register.');
  } # end age check
   }

Bobby

Link to comment
Share on other sites

I understand what you are saying, but i dont really care if they lie about their age. There is nothing i can do to stop them, except pop around their house and ask for a copy of their birth certificate. LOL

 

Its just for legal reason's, i can get fined for supplying goods to underage people. I can easily put on the create account file "you must be 18 years or over to apply" but just thought it would be a nice feature to have. I also have it stated on my terms.

 

Maybe you are right, and i dont really need it.. but it would be nice to have.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...