<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');
}
}
}