所属分类:PHP实例-常用实例教程
滑动验证码表单,action提交到当前页面
<form method="post" action=""> <label>姓名</label> <input type="text" name="username" /> <input type="submit" name="submit" value="提交表单" /> </form>
引入验证码插件
<script type="text/javascript" src="jquery/jquery.js"></script> <script type="text/javascript" src="jquery/jquery-ui.js"></script> <script type="text/javascript" src="jquery/jquery.ui.touch.js"></script> <script type="text/javascript" src="jquery/QapTcha.jquery.js"></script>
调用QapTcha验证码插件
$(document).ready(function() { $('.QapTcha').QapTcha(); });
PHP提交表单验证
if (isset($_POST['submit'])) { $response = '<div class="notice">'; /** SESSION CONTROL * */ if (isset($_SESSION['qaptcha_key']) && !empty($_SESSION['qaptcha_key'])) { $QaptChaInput = $_SESSION['qaptcha_key']; if (isset($_POST['' . $QaptChaInput . '']) && empty($_POST['' . $QaptChaInput . ''])) $response .= '表单已提交<br />姓名 : ' . $_POST['username']; else $response .= '$_POST not empty or unexists'; } else $response .= '没有SESSION.. 表单不能提交...'; $response .= '</div>'; echo $response; unset($_SESSION['qaptcha_key']); }