本文整理汇总了PHP中Model\User::isUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP User::isUsername方法的具体用法?PHP User::isUsername怎么用?PHP User::isUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model\User
的用法示例。
在下文中一共展示了User::isUsername方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isset
* @version GIT: $Id$
* @link http://www.168helps.com/blog
*/
use Model\User;
use Util\Token;
use Form\Response;
if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
$userPostData = isset($_POST['user']) && is_array($_POST['user']) ? $_POST['user'] : array();
$userPostData = array_map('trim', $userPostData);
$username = isset($userPostData['name']) ? $userPostData['name'] : '';
$password = isset($userPostData['pass']) ? $userPostData['pass'] : '';
//进行表单令牌验证
if (Token::validate($_POST['token']) === false) {
Response::json(array('msg' => '非法访问,请刷新表单'), 1);
}
if (User::isUsername($username) == false) {
Response::json(array('msg' => '账号不符合规则,请重新输入'), 1);
}
if (User::isPassword($password) == false) {
Response::json(array('msg' => '密码不符合规则,请重新输入'), 1);
}
$userData = User::getUserDataByUsername('user_id,user_pass', $username);
if (isset($userData['user_id']) == false) {
Response::json(array('msg' => '您输入的帐号不存在,请重新输入'), 1);
}
if (md5($password) != $userData['user_pass']) {
Response::json(array('msg' => '您输入的密码有误,请重新输入'), 1);
}
$_SESSION['user_id'] = $userData['user_id'];
$_SESSION['user_name'] = $username;
Response::json(array('msg' => '系统登录成功'), 0);
示例2: isset
* @package user
* @author zhaoyan <1210965963@qq.com>
* @license https://github.com/3032441712/person/blob/master/LICENSE GNU License
* @version GIT: $Id$
* @link http://www.168helps.com/blog
*/
use Model\User;
use Form\Response;
$eid = isset($_GET['eid']) ? intval($_GET['eid']) : '';
$act = isset($_GET['act']) ? $_GET['act'] : '';
if ($act == 'save') {
$userData = isset($_POST['user']) && is_array($_POST['user']) ? $_POST['user'] : array();
$data = array('user_name' => isset($userData['name']) ? $userData['name'] : '', 'user_pass' => isset($userData['pass']) && $userData['pass'] != '' ? md5($userData['pass']) : '', 'user_real_name' => isset($userData['real_name']) ? $userData['real_name'] : '', 'user_sex' => isset($userData['sex']) && $userData['sex'] != '' ? $userData['sex'] : 1, 'user_age' => isset($userData['age']) && $userData['age'] != '' ? $userData['age'] : 0, 'user_email' => isset($userData['email']) ? $userData['email'] : '', 'user_qq' => isset($userData['qq']) && $userData['qq'] != '' ? $userData['qq'] : 0, 'user_phone' => isset($userData['phone']) && $userData['phone'] != '' ? $userData['phone'] : 0, 'user_mobile' => isset($userData['mobile']) && $userData['mobile'] != '' ? $userData['mobile'] : 0);
//去除数据两侧空字符
$data = array_map('trim', $data);
if (User::isUsername($data['user_name']) == false) {
Response::json(array('msg' => '用户名不符合规则,请重新输入'), 1);
}
if ($eid > 0) {
if ($data['user_pass'] != '' && User::isPassword($data['user_pass']) == false) {
Response::json(array('msg' => '密码不符合规则,请重新输入'), 1);
}
} else {
if (User::isPassword($data['user_pass']) == false) {
Response::json(array('msg' => '密码不符合规则,请重新输入'), 1);
}
}
//真实姓名
if ($data['user_real_name'] != '' && User::isRealName($data['user_real_name']) == false) {
Response::json(array('msg' => '输入的名字不符合规则,请重新输入'), 1);
}