tp5验证

<?php
  namespace app\admin\Controller;
  
  use think\Request;
  use think\Controller;    
  use think\Validate;
     Class Yz extends Controller{             
           public function text(){
           return view();
   }
        public function text7(){                      
            $data = input('post.');                     
            $validate = new Validate([             
            'uid'=>'require|length:5,10',        
            'pwd'=>'require|confirm:repassword'
            ],[
            'uid.require'=>'用户名不能为空',
            'uid.length'=>'长度符合'
            ]);
            if($validate->check($data)){
                
            }else{
                $this->error($validate->getError());
            }
        }
   
     }
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <form action="{:url('text7')}" method="post">
                帐号:<input type="text" name="uid" value=""/>
                密码:<input type="password" name="pwd" value=""/>
             再次输入 密码:<input type="password" name="pwd" value=""/>
            <input type="submit" value="登录"/>
        </form>
    </body>
</html>

posted @ 2018-08-05 16:08  所爱隔山隔海  阅读(144)  评论(0编辑  收藏  举报