所属分类:PHP实例-常用实例教程
首先我们在表单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>然后我们放置输入验证码框、声音flash和提交按钮
<p><input type="text" name="captcha_code" size="10" maxlength="6" /></p> <object type="application/x-shockwave-flash" data="securimage/securimage_play.swf?audio_file=securimage/securimage_play.php&bgColor1=#fff&bgColor2=#fff& iconColor=#777&borderWidth=1&borderColor=#000" width="19" height="19"> <param name="movie" value="securimage/securimage_play.swf?audio_file=securimage/securimage_play.php&bgColor1=#fff& bgColor2=#fff&iconColor=#777&borderWidth=1&borderColor=#000" /> </object> <p><input type="submit" class="btn" value="提交"/></p>表单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'验证码正确!'; }