Go Back   CP Web Hosting - reseller hosting > Server Scripting > PHP
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-28-2007, 10:31 AM
Senior Member
 
Join Date: Mar 2007
Posts: 193
Default Age verifcation code

Hello friends,

I am looking for a script or code to put it on a index page of adult site that asks for visitors age and verified it

can anyone help me with this please
Reply With Quote
  #2 (permalink)  
Old 06-28-2007, 10:35 AM
Senior Member
 
Join Date: Apr 2007
Posts: 347
Default

Quote:
Originally Posted by stevon View Post
Hello friends,

I am looking for a script or code to put it on a index page of adult site that asks for visitors age and verified it

can anyone help me with this please

why php, u can also do it with the use of HTML
Reply With Quote
  #3 (permalink)  
Old 06-28-2007, 10:36 AM
Senior Member
 
Join Date: Apr 2007
Posts: 347
Default

Quote:
Originally Posted by stevon View Post
Hello friends,

I am looking for a script or code to put it on a index page of adult site that asks for visitors age and verified it

can anyone help me with this please

why script, u can also do it with the use of HTML
Reply With Quote
  #4 (permalink)  
Old 06-28-2007, 10:39 AM
Senior Member
 
Join Date: Mar 2007
Posts: 193
Default

Quote:
Originally Posted by stargate View Post
why script, u can also do it with the use of HTML
No, I dont want this in HTML so that user has to go thru this every time.. i want it to set a cookie if user has already entered his/her age... once he dont have to do it again..
Reply With Quote
  #5 (permalink)  
Old 06-28-2007, 10:40 AM
Senior Member
 
Join Date: May 2007
Posts: 284
Default

Use this PHP code

Code:
<?php

$verified = false;

if ($_POST['verify'])
{
    extract(array_map('intval', $_POST));
   
    if (!checkdate($month, $day, $year))
    {
        exit('Invalid birthday.');
    }
   
    $now = mktime(0, 0, 0);
    $birthday = mktime(0, 0, 0, $month, $day, $year);
    $age = intval(($now - $birthday) / (3600 * 24 * 365));

    if ($age >= 18)
    {
        setcookie('age_verified', 1, time()+3600*24*7, '/');
        $verified = true;
    }
    else
    {
        echo 'Sorry, you are too young.';
    }
}


?>

<?php

if (isset($_COOKIE['age_verified']) OR $verified)
{
    // Page content
}
else
{
?>
<form action="" method="post">
<select name="day">
<option>Day</option>

<?php
   
for ($day = 1; $day <= 31; $day++)
{
    echo "\t". '<option value="'. $day .'">'. $day ."</option>\n";
}
?>
</select>

<select name="month">
<option>Month</option>

<?php
   
for ($month = 1; $month <= 12; $month++)
{
    echo "\t". '<option value="'. $month .'">'. $month ."</option>\n";
}
?>
</select>


<select name="year">
<option>Year</option>
<?php
   
for ($year = date('Y')-80; $year <= date('Y'); $year++)
{
    echo "\t". '<option value="'. $year .'">'. $year ."</option>\n";
}
?>
</select>

<input type="submit" name="verify" value="Submit" />
</form>


<?php
}
?>
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 07:35 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0