<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # thinkphp5.0內置的驗證登錄的方法 ## 代碼使用如下: ~~~ public function reqister(Request $request){ $rule=['username'=>'require|length:6,12','email'=>'require']; //reqyure為非空的意思 length為字符串長度的意思 username email為html提交來的表單名稱 $validate= new Validate($rule); //實例化Validate $data=$request->param(); //獲取輸入的POST值 if(!$validate->check($data)) { //判斷如果為假,輸出驗證失敗的信息 $this->success($validate->getError(),'/index'); //驗證失敗后跳轉到首頁 } else{ dump('驗證成功'); //驗證成功后 } } ~~~ ![](https://img.kancloud.cn/4b/32/4b32c0878a828b7a9712e7fdf80f7ce1_1410x699.png) ## 自定義驗證規則 ![](https://img.kancloud.cn/1c/f5/1cf5e27b9bb6443af88e9bc6107a09f6_1157x413.png) ## 自定義的驗證方法用正則表達式 ~~~ <?php namespace app\index\controller; use think\Controller; use think\Db; use app\index\model\Maik; use think\Session; use think\Cookie; use think\Validate; use think\Request; class Index extends Controller { public function index(){ return $this->fetch(); } public function reqister(Request $request){ $rule=['username'=>'\w{4}','email'=>'require|email']; //自定義條件用正則方法 $rule為內置的變量不能改名 $message=['username'=>'用戶名長度必須是4位', 'email.require'=>'郵箱不能為空', //自定義錯誤數組 //$message為內置的變量不能改名 'email.email'=>'郵箱格式不正確' ]; $validate= new Validate($rule,$message); //實例化Validate $data=$request->param(); //獲取輸入的POST值 if(!$validate->check($data)) { //判斷如果為假,輸出驗證失敗的信息 $this->success($validate->getError(),'/index'); //驗證失敗后跳轉到首頁 } else{ dump('驗證成功'); //驗證成功后 } } } ~~~ ## 自定義截圖: ![](https://img.kancloud.cn/4e/73/4e733900b88de8a2c060da4a25fae2c5_1341x637.png) ## index.html里文件 ~~~ <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <form action="reqister" method="post"> 用戶名: <input type="text" name="username"> 郵箱: <input type="text" name="email"> <button>注冊</button> </form> </body> </html> ~~~ Route路由里: ``` Route::post('reqister','index/index/reqister'); ``` ## 內置驗證規則 http://www.hmoore.net/manual/thinkphp5/129356
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看