tp5 验证码功能实现

视图层

<div class="loginbox-textbox">
  <input class="form-control" placeholder="请输入验证码" name="captcha" type="text"/>
  <img id="cap" alt="验证码" title="点击刷新" style="220px;cursor: pointer;    margin: 20px 0;border:2px solid rgb(220, 222, 224);" onclick="this.src='{:captcha_src()}'" src="{:captcha_src()}"/>
</div>

控制器验证

//接收数据
$captcha = input("post");


if(!captcha_check($captcha['captcha'])){
     //输入的验证码错误
}else{
        //输入的验证码正确
}
原文地址:https://www.cnblogs.com/junyi-bk/p/10811634.html