litto/captcha

PHP表单中的验证码验证

v3.0 2022-02-07 07:10 UTC

This package is auto-updated.

Last update: 2024-09-07 12:56:15 UTC


README

为PHP网站提供的简单验证码

如何安装?

您可以通过composer安装它,输入以下命令:

composer require litto/captcha:v2.0

它是如何工作的?

在表单中添加以下内容:

       <img src="captcha.php" alt="captcha" title="captcha" class="captcha" width="100px" height="50px">
          <label for="email2">Enter Code</label>
          <input  class="form-control"  name="txtCode"  type="text"  value="Captcha">

在表单提交函数中,只需这样做:

session_start(); $text=$_SESSION["vercode"] ; unset($_SESSION["vercode"]); $captcha = $_POST['txtCode']; if($captcha==$text) { // 保存函数 }else{ // 验证码验证错误 }