validate age before registering a user to check if hes over a certain age using mvc(在注册用户之前验证年龄以使用 mvc 检查他是否超过特定年龄)
问题描述
我必须开发一个表格,该表格可以记录用户年龄并计算年龄,如果超过 18 岁,则将他带到注册表格
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
我的问题是我正在使用 zend 框架如何实现它,当它不应该与模型进行太多交互并且数据库中没有数据时
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
如何验证人的年龄
我正在尝试使用此代码
$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
}
这篇关于在注册用户之前验证年龄以使用 mvc 检查他是否超过特定年龄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在注册用户之前验证年龄以使用 mvc 检查他是否超
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- PHP - if 语句中的倒序 2021-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
