神速代码

<?php
002/**
003 * App用户注册接口
004 * return: json
005 */
006public function signup_old(){
007    $yyUser = M('table.user','youyax_');
008    $data['user'] = $_POST['userName'];
009    $data['telephone'] = $_POST['telephone'];
010    $password = $_POST['password'];
011    $repassword = $_POST['repassword'];
012    $data['beAgent'] = $_POST['beAgent'];
013    $data['realName'] = $_POST['realName'];
014    $data['email'] = $_POST['email'];
015    $data['credit'] = I('identityCard');
016    if(empty($data['user']) || empty($password) || empty($repassword) || empty($data['email']) ){
017        $arr['code'] = 0;
018        $arr['message'] = '必填项不能为空!';
019        echo json_encode($arr);
020        return false;
021    }
022    $lenP = strlen($password);
023    if($lenP < 6 || $lenP >20){
024        $arr['code'] = 0;
025        $arr['message'] = '密码必须为6-20位!';
026        echo json_encode($arr);
027        return false;
028    }
029    if( empty($data['beAgent']) ){
030        $data['beAgent'] = 0;
031    }
032    if($data['beAgent'] == 1){
033        if(empty($data['realName']) || empty($data['telephone']) || empty($data['credit'])){
034            $arr['code'] = 0;
035            $arr['message'] = '经纪人必须填写手机号、真实姓名、身份证号!';
036            echo json_encode($arr);
037            return false;
038        }
039        $creditLength = strlen($data['credit']);
040        if (!in_array($creditLength, array(15, 18)))
041            $this->response(0, '身份证号码不合法');
042    }
043    $verifyE = $this->checkEmail($data['email']);
044    if($verifyE){
045        $email = $data['email'];
046        $mapE['email'] = array('in',$email);
047        $count = $yyUser->where($mapE)->count();
048        if($count==0){
049            if($repassword == $password){
050                $data['pass'] = md5($password);
051                $userName = $data['user'];
052                $mapU['user'] = array('in',$userName);
053                $count = $yyUser->where($mapU)->count();
054                if($count==0){
055                    $tel = $data['telephone'];
056                    $verifyT = $this->checkTel($tel);
057                    if( !empty($data['telephone'])){
058                        if(!$verifyT){
059                            $arr['code'] = 0;
060                            $arr['message'] = '不是正确的手机号码!';
061                            echo json_encode($arr);
062                            return false;
063                        }
064                        $mapT['telephone'] = array('in',$tel);
065                        $count = $yyUser->where($mapT)->count();
066                        if($count!=0){
067                            $arr['code'] = 0;
068                            $arr['message'] = '手机号码已被使用!';
069                            echo json_encode($arr);
070                            return false;
071                        }
072                    }
073                    $data['status'] = 1;
074                    $bools = $yyUser->add($data);
075                    if($bools){
076                        $id = $yyUser->field('id')->where('user = '.'"'.$data['user'].'"')->select();
077                        $userId = $id[0]['id'];
078                        $arr['code'] = 1;
079                        $arr['message'] = '注册成功!';
080                        $arrData['userId'] = $userId;
081                        $arrData['userName'] = $data['user'];
082                        $arrData['beAgent'] = $data['beAgent'];
083                        $arrData['realName'] = $data['realName'];
084                        $arrData['password'] = $data['pass'];
085                        $arrData['email'] = $data['email'];
086                        $arr['data'] = $arrData;
087                        echo json_encode($arr);
088                    }else {
089                        $arr['code'] = 0;
090                        $arr['message'] = '注册失败,系统异常,请重新注册!';
091                        echo json_encode($arr);
092                    }
093                }else {
094                    $arr['code'] = 0;
095                    $arr['message'] = '用户名已被使用!';
096                    echo json_encode($arr);
097                }
098            }else {
099                $arr['code'] = 0;
100                $arr['message'] = '密码不一致!';
101                echo json_encode($arr);
102            }
103        }else {
104            $arr['code'] = 0;
105            $arr['message'] = '手机号码已被使用!';
106            echo json_encode($arr);
107        }
108    }else {
109        $arr['code'] = 0;
110        $arr['message'] = '手机号码不合法';
111        echo json_encode($arr);
112    }
113}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值