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