HTML
首先我们在表单form放置一个验证码图片,并且点击它可以刷新验证码。
<a href="#" onclick="document.getElementById('captcha').src = './securimage/securimage_show.php?' + Math.random(); return false"><img id="captcha" src="./securimage/securimage_show.php" alt="CAPTCHA Image"/> </a>
表单check.php
include_once('./securimage/securimage.php'); session_start(); $securimage = new Securimage(); var_dump($_SESSION); if($securimage->check($_POST['captcha_code']) == false){ echo "错误,<a href='javascript:history.go(-1)'>返回</a>重试"; exit; }else{ echo'验证码正确!'; }