Home  >  Article  >  Backend Development  >  1.如何判断时间格式是否正确 2.如何判断用户登录权限

1.如何判断时间格式是否正确 2.如何判断用户登录权限

WBOY
WBOYOriginal
2016-06-23 14:19:42923browse

PHP

1.如何判断时间格式是否正确:

  如:我需要 20110603 这样的格式,这个格式是用户自行填写的,如何判断 用户填写的是否符合这个规范,
      需要代码借鉴

2.如何判断用户登录权限:

  如: 用户登录之后,复制某一个地址路径进行链接,设置成用户不能访问此路径,需要代码借鉴


希望大神们 指点   

回复讨论(解决方案)



大神,快来指点....

1.可以用日期控件http://www.my97.net/或正则匹配http://hi.baidu.com/tuqin526/item/f1a0becfae508435459416ab
2.需要有个权限表记录下用户ID和链接,当用户访问这个链接,判断权限表中是否有对应的用户ID

$d = '20110603';if(date('Ymd', strtotime($d)) == $d) echo '格式正确';


if(! $_SERVER['HTTP_REFERER']) die('无权访问');

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn