Home  >  Q&A  >  body text

When verifying the phone, it jumps to the registration page without any prompt.

When verifying the mobile phone, it will jump to the registration page without any prompts

The previous email address and user name can be verified normally

王先生王先生1780 days ago1439

reply all(5)I'll reply

  • 王先生

    王先生2019-11-06 11:54:51

    Solved, it turned out that the name attribute setting on the registration page was wrong

    reply
    0
  • 王先生

    王先生2019-11-06 09:38:48

    There is too much content on the registration page, and it seems that it cannot be posted.

    The registration page is exactly the same as what the teacher wrote

    reply
    0
  • 王先生

    王先生2019-11-06 09:15:09

    Controller

    namespace app\index\controller;
    use app\common\controller\Base;
    use think\facade\Request;
    use app\common\model\ User as UserModel;
    class User extends Base
    {
    //Registration page
    public function register()
    {
    $this->assign('title','User Register');
    return $this->fetch();
    }

    //Process the registration information submitted by the user
    public function insert()
    {
    If (request :: isajax ())
    {
    /**
                  * Use models to create data
                     #&*/##// Verification data
    $ data = request :: Post (); // Data
              $rule= 'app\common\validate\User';//Customized validation rules
                $res=$this->validate($data,$rule);//Start validating data
                                                                                                                                                                                            ’ ’ s         ’ s ’ ’ s ’ ’ s ’ ’ s ’ ’ s ’ t ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ 1 ];
    }
    Else
    {
    // If the data is correct
    if (usermodel :: create ($ data))
    {
    Return ['Status' = & GT ;1,'message'=>'Congratulations, the registration is successful'];
                    }
                      else
                                                        ‐               ‐ ‐ } ‐ ‐ ‐ ‐‐                                                                                                                                            '=>'Register Failure, please check '];
    }
    }

    }
    Else
    {
    $ this-& gt error ("" Request Type Error ",' Register ') ;
    }
    }

    }

    reply
    0
  • 王先生

    王先生2019-11-06 09:14:40

    Validation rules namespace app\common\validate\User.php:

    namespace app\common\validate;
    use think\Validate;
    class User extends Validate
    {
    /**
    * Current validation rules
    * @var array
    */
    protected $rule = [
    /**
    * Another way of writing:
    * * 'name|Username'=>'require|length:5,20|chsAlphaNum',
    * 'email|Mailbox'=>'require|email |unique:zh_user',
    * 'password|password'=>'require|alphaNum|length:6,20|confirm',
    * 'mobile|手机'=>'require|mobile|unique :zh_user|number'
    */
    'name|username'=>[
    'require'=> 'require',
    'length'=>'5,20',
    'chsAlphaNum'=>'chsAlphaNum',//Only Chinese characters, characters and numbers are allowed
    ],
    ' email|Mailbox'=>[
                        'require'=>'require',
              'unique'=>'zh_user',//This field value is unique in the zh_user table email'=>'email',
              ],
                                                                                                                                                                                                                                ‐ ’ ’ ’ s ’ s ’ being  ',
            'unique'=>'zh_user',//This field value is unique in the zh_user table
                'number'=>'number',
              ],
              'password | Password '= & gt; [
    ' requine '= & gt;' reques,
    'alphaanum' = & gt; 'alphaum', // Only allow letters plus numbers
    'length' = & gt; ' 6,20',//Length limit
                'confirm'=>'confirm',//Automatically perform equality verification with the password_confirm field
                                                                                                                             #

    reply
    0
  • 卢小强

    卢小强2019-11-06 08:54:38

    Post the code and take a look

    reply
    0
  • Cancelreply