Recently, I came into contact with a new PHP verification code tool - Securimage in the project. It is very simple and convenient to use, and supports ajax calls, so I recommend it to everyone here.
What is Securimage?
Securimage is an open source/free phpCAPTCHA script that can be used to generate complex verification code images to help your website prevent spam. It can be easily embedded into existing forms on your website, providing your website with protection from spam bots. It can run on most webservers that support PHP (GD).
*Click here for quick guide
*Securimage instance
* Download the latest version
of Securimage Features:
* Display verification code with just three lines of code
* Only six lines of code can be used to verify the input of the verification code
* Customize verification code length
* Custom character set
* Support TTF
* Use custom GD font (if TTF does not support it)
* Easily add custom background images
* Rich text support including color/angle/transparency options
*Arched lines through text
* Generate CAPTCHA audio files in wav format
Here is a simple example
of customizing the CAPTCHA verification code list
:<html>
<head>
<title>Securimage Test Form</title>
</head>
<body>
<?php
if (empty($_POST)){?>
<form method="POST">
Username:<br />
<input type="text" name="username" /><br />
Password:<br />
<input type="text" name="password" /><br />
<!-- Call securimage to display the verification code image, sid is used to prevent being cached -->
<img src="securimage_show.php?sid=<?php echomd5(uniqid(time()));?>"><br />
<input type="text" name="code" /><br />
<input type="submit" value="Submit Form" />
</form>
<?php
} else{//form is posted
include("securimage.php");
$img=new Securimage();
$valid=$img->check($_POST['code']);//Check whether the user's input is correct
if($valid==true) {
echo "<center>Thanks, you entered the correct code.</center>";
} else{
echo "<center>Sorry, the code you entered was invalid. <a href="javascript:history.go(-1)">Go back</a> to try again.</center>";
}
}
?>
</body>
</html>
Code of securimage_show.php:
<?php
include 'securimage.php';//Download the core class library code in the package
$img=new securimage();
$img->show();// alternate use: $img->show('/path/to/background.jpg');
?>