ThinkPHP 5 验证码

时间:2023-03-08 16:09:45
<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');
}
}
}

ThinkPHP 5 验证码