ThinkPHP 5 验证码

<div>
    <form action="{:url('index/check')}" method="post">
        <img src="{:captcha_src()}" alt="captcha" />
        <input type="text" name="captcha" id="captcha">
        <input type="submit" value="提交">
    </form>
</div>
<?php
namespace app\index\controller;
use think\Controller;
class Index extends Controller
{
    public function index()
    {
        return $this->fetch();
    }
    public function check()
    {
        $captcha = input('captcha');
        if (captcha_check($captcha)) {
            $this->success('Success');
        } else {
            $this->error('Error');
        }
    }
}

posted @ 2018-03-05 13:47  liessay  阅读(245)  评论(0编辑  收藏  举报