本文整理汇总了PHP中User\Api\UserApi::checkUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP UserApi::checkUsername方法的具体用法?PHP UserApi::checkUsername怎么用?PHP UserApi::checkUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User\Api\UserApi
的用法示例。
在下文中一共展示了UserApi::checkUsername方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
public function validate()
{
if (!C('USER_ALLOW_REGISTER')) {
$this->ajaxErr(-1, '注册已关闭');
}
$type = I('type', 'default');
$value = I('val', '');
$ok = rand(0, 3) > 1 ? true : false;
$User = new UserApi();
$msgMap = array("-1" => "用户名长度不合法", "-2" => "用户名禁止注册", "-3" => "用户名被占用", "-4" => "密码长度不合法", "-5" => "邮箱格式不正确", "-6" => "邮箱长度不合法", "-7" => "邮箱禁止注册", "-8" => "邮箱被占用", "-9" => "手机格式不正确", "-10" => "手机禁止注册", "-11" => "手机号被占用");
switch ($type) {
case 'default':
$this->ajaxErr(-1, '参数错误');
break;
case 'username':
$ret = $User->checkUsername($value);
if ($ret == 1) {
$this->ajaxSucc();
} else {
$this->ajaxErr($ret, $msgMap[$ret]);
}
break;
case 'mobile':
$ret = $User->checkMobile($value);
if ($ret == 1) {
$this->ajaxSucc();
} else {
$this->ajaxErr($ret, $msgMap[$ret]);
}
break;
case 'email':
$ret = $User->checkEmail($value);
if ($ret == 1) {
$this->ajaxSucc();
} else {
$this->ajaxErr($ret, $msgMap[$ret]);
}
break;
}
}
示例2: add
public function add()
{
if (IS_POST) {
//检测是否传来用户密码,如用户不存在,先建用户
$User = new UserApi();
if (I('post.username')) {
$res = $User->checkUsername("xiaobai");
if ($res) {
$res_user = $User->register(I('username'), I('password'), I('email', '1@1.com'));
if (!$res_user) {
$this->error("创建用户失败,您可以先注册用户先试");
}
}
}
$qianzui = C('SESSION_PREFIX');
$uid = $_SESSION[$qianzui]['user_auth']['id'];
/*if(I('post.username')){
$res=chack_username(I('post.username'));
if($res){
$this->error("用户名以存在");
}else{
$res_user=create_user(I('post.username'),I('post.password'));
if($res_user){
$qianzui=C('SESSION_PREFIX');
$_SESSION[$qianzui]['m_user']['id']=$res_user;
$_SESSION[$qianzui]['m_user']['username']=I('post.username');
}else{
$this->error("创建用户失败,您可以先注册用户先试");
}
}
}*/
if (!$uid && !UID) {
$this->error("未知错误,请联系网站管理员");
}
$wmpdb = M('weimingpian');
/*
if($_SESSION[$qianzui]['m_user']){
$result=$wmpdb->where(array('uid'=>$_SESSION[$qianzui]['m_user']['id']))->find();
if($result){
$this->error("一个普通用户只可以创建一个名片,想创建更多名片请注册商家用户(免费)");
}
}*/
$wmpdb->create();
$wmpdb->uid = $uid ? $uid : UID;
$storeid = $_SESSION['onethink_admin']['user_auth']['uid'] || 0;
$wmpdb->storeid = $storeid;
$wmpdb->district = I('sheng') . ',' . I('shi');
$wmpdb->trade = I('post.trade');
$res = $wmpdb->add();
if ($res) {
$this->success("名片添加成功", U('index', array('id' => $res)));
} else {
$this->error("添加失败");
}
} else {
$this->tradelist = M('trade')->select();
$this->display();
}
}