validate age before registering a user to check if hes over a certain age using mvc
hi i have to develop a form which takes user age and calculates age and if over 18 procedds to take him to registeration form
my question is has i am using zend framework how to implement it when its not supposed to interact with model much and their is no data in database
how can i valid开发者_运维问答ate age of the person
i m trying to use this code
$data = array ( 'dob' => date ( "Y-m-d" ));
$select = $db
->select()
->from('data', array(
'id',
'age' => new Zend_Db_Expr("DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS(dob)), '%Y')+0")))
can i use an array ? please help me friendshow should be this query
I don't quite understand your question... Are you having trouble calculating the age from a DOB?
If so, this should take care of your problem:
function Age($date = 'now')
{
return intval(substr(date('Ymd') - date('Ymd', strtotime($date)), 0, -4));
}
var_dump(Age('1975-04-25')); // int(36)
if (Age('1975-04-25') >= 18)
{
// proceed to registration
}
精彩评论