About automatic verification issues in ThinkPHP
滿天的星座
滿天的星座 2017-05-16 13:09:54
0
3
567

![Picture uploading...]

 public function addUserBasicData($username,$password,$user_type,$email,$phone,$onlyuid = '598E0CD9'){
        if (empty($username)) {
            $username = "User".mt_rand();
        }
        $data['username'] = $username;
        $data['onlyuid'] = $onlyuid;
        $data['password'] = $password;
        $data['user_type'] = $user_type;
        $data['email'] = $email;
        $data['phone'] = $phone;
        $data['regdate'] = NOW_TIME;

        $rules = array(
            array('onlyuid','','Duplicate identity',0,'unique',1),
            array('phone','require','Illegal mobile phone number','/^(13|14|15|16|17|18)\d{9}$$/'),
            array('phone','','The mobile phone number you entered has been registered!',0,'unique',1),
            array('email','','The email address you entered has already been registered!',0,'unique',1),
            array('password','require','You have not filled in the password yet!'),
            array('user_type','require','You have not selected a user type!'),
            array('repassword','password','Confirm the password is incorrect',0,'confirm'),
            array('password','checkPwd','Password format is incorrect',0,'function'),
        );
        if (!$this->table('yy_common_member')->validate($rules)->create()){
            $return_value["status"] = "failed";
            $return_value["status_code"] = 40000;
            $return_value["status_message"] = $this->getError();;
            $return_value["data"]= "";
            return $return_value;
               
        }else{
            $uid = $this->table('yy_common_member')->add($data);
            $data2['uid'] = $uid;
            $return_value["status"] = "success";
            $return_value["status_code"] = 20105;
            $return_value["status_message"] = "";
            $return_value["data"]= $this->table('yy_common_member_profile')->add($data2);
            return $return_value;
        }

    }

The above is a code snippet
set respectively
array('onlyuid','','duplicate identity',0,'unique',1), and array('phone','',' The mobile phone number you entered has already been registered! ',0,'unique',1), Verification rules for
.
But the former does not take effect, the latter can be used

Error reporting
< /span>

Normal
< /span>

滿天的星座
滿天的星座

reply all(3)
世界只因有你

This is obviously an error reported by the sql statement. It has nothing to do with verification. The onlyuid inserted is repeated

过去多啦不再A梦

What is the data type of the onlyuid field in your database?

世界只因有你

Everyone is right: the reason is in the database, you are trying to insert a duplicate onlyuid, and this field is obviously set to be unique.

Check it. If the literal meaning of this field is not very strong, it is recommended to use the auto-increment form. Do not skip this field directly every time you insert data and let it increase by itself.

There is also a possibility that the value to be inserted in this field has exceeded its maximum allowed value.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template