首页 > 作文

thinkphp5调用验证码并校验是否正确的方法整理

更新时间:2023-04-09 00:47:28 阅读: 评论:0

thinkphp5调用验证码并校验是否正确的方法整理

thinkphp5的验证码路径login页面login控制器的check方法

thinkphp5的验证码路径

http://app.thinkphpwu.com/captcha

login页面

<!DOCTYPE HTML><html><head><meta chart="utf-8"><meta name="renderer" content="webkit|ie-comp|ie-stand"><meta http-equiv秦君="X-UA-Compatible" content="IE=edge,chrome=1"><meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,ur-scalable=no"/><meta http-equiv="Cache-Control" content="no-siteapp"/><!--[if lt IE 9]> <script type="text/javascript" src="__STATIC__/hadmin/lib/html5shiv.js"></script> <script type="text/javascript" src="__STATIC__/hadmin/lib/respond.min.js"></script> <![endif]--><link href="__STATIC__/hadmin/static/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css"/><link href="__STATIC__/hadmin/static/h-ui.admin/css/H-ui.login.css" rel="stylesheet" type="text/css"/><link href="__STATIC__/hadmin/static/h-ui.admin/css/style.css" rel="stylesheet" type="text/css"/><link href="__STATIC__/hadmin/lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" type="text/css"/><!--[if IE 6]> <script type="text/javascript" src="__STATIC__/hadmin/lib/DD_belatedPNG_0.0.8a-min.js"></script> <script>DD_belatedPNG.fix('*');</script> <![endif]--><title>后台登录 - H-ui.admin v3.1</title><meta name="keywords" content="奇葩天地网,www.qipa250.com"><meta name="description" content="奇葩天地网"></head><body><input type="hidden" id="TenantId" name="TenantId" value=""/><div class="header"></div><div class="loginWraper"><div id="loginform" class="loginBox"><form class="form form-horizontal" action="{:url('login/check')}" method="post"><div class="row cl"><label class="form-label col-xs-3"><i class="Hui-iconfont"></i></label><div class="formControls col-xs-8"><input id="urname" name="urname" type=月的诗句"text" placeholder="账户" class="input-text size-L"></div></div><div class="row cl"><label class="form-label col-xs-3"><i class="Hui-iconfont"></i></label><div class="formControls col-xs-8"><input id="password" name="password" type="password" placeholder="密码" class="input-text size-L"></div></div><div class="row cl"><div class="formControls col-xs-8 col-xs-offt-3"><in定向调剂put class="input-text size-L" type="text" placeholder="验证码" name="code" onblur="if(this.value==''){this.value='验证码:'}" onclick="if(this.value=='验证码:'){this.value='';}" value="验证码:" style="width:150px;"><img src="/captcha" title="看不清,换一张" onclick="reloadCaptcha(this)"></div></div><div class="row cl"><div class="formControls col-xs-8 col-xs-offt-3"><label for="online"><input type="checkbox" name="online" id="online" value="">使我保持登录状态</label></div></div><div class="row cl"><div class="formControls col-xs-8 col-xs-offt-3"><button type="submit" class="btn btn-success radius size-L">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</button><button type="ret" class="btn btn-default radius size-L">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</button></div></div></form></div></div><div class="footer">奇葩天地网 by www.qipa250.com v3.1</div><script type="text/javascript" src="__STATIC__/hadmin/lib/jquery/1.9.1/jquery.min.js"></script><script type="text/javascript" src="__STATIC__/hadmin/static/h-ui/js/H-ui.min.js"></script><script type="text/javascript"> //点我刷新验证码 function reloadCaptcha(code_img) {  code_img.src = '/captcha?id=' + Math.random(); } </script></body></html>

login控制器的check方法

<?phpnamespace app\admin\controller;u think\Controller;class Login extends C天然气化学式ontroller{ public function index(){ //加载视图文件return $this->fetch();}//验证用户名密码public function check(){ //得到提交的表单信息$data = input('post.');dump($data);//验证码判断if (!captcha_check($data['code'])) { $this->error('验证码不正确!');}}}

开始验证
输入错误的验证码
报错

输入正确的验证码

没报错

本文地址:https://blog.csdn.net/guo_qiangqiang/article/details/111116367

本文发布于:2023-04-09 00:47:27,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/9a971927f656312859e021895c40ca55.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:thinkphp5调用验证码并校验是否正确的方法整理.doc

本文 PDF 下载地址:thinkphp5调用验证码并校验是否正确的方法整理.pdf

标签:验证码   奇葩   方法   报错
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图