tp5-验证码

HTML代码:

<img onclick="this.src='{:captcha_src()}?'+Math.random()" src="{:captcha_src()}" alt="captcha" />

 

namespace app\admin\controller;
use think\Controller;
use app\admin\model\Admin;
class Login extends Controller
{
    public function index()
    {
        if(request()->isPost()){
            $admin = new Admin();
            $data=input('post.');
            if($admin->login($data)==3){
                $this->success("信息正确,正在为您跳转",'index/index');
            }else if($admin->login($data)==4){
                $this->error('验证码错误');
            }
            else{
                $this->error("用户名或密码错误");
            }
        }
        return $this->fetch();
    }

}

 

posted @ 2021-01-06 11:02  soda001  阅读(58)  评论(0)    收藏  举报