- Name : PD Captcha PHP
- Author : Partharaj Deb
- Date : 23 December 2017
- Description : This library is able to create captcha code which can be used in form to improve security.
- Speciality : It does not generate any image file. All functionality are done in a single file (captcha.php).
- Create a new captcha code
pdCaptchaCreate(); - Get captcha image url to show in the user interface using
imgtag.
pdCaptchaImageSrc();- Get captcha code in plain text to compare with user input
pdCaptchaCode();session_start();
require_once "./pd-captcha-php/captcha.php"; // Path to the captcha.php
// Creates new captcha
pdCaptchaCreate();
// pdCaptchaImageSrc() returns the image src path.
<img src="<?= pdCaptchaImageSrc() ?>" alt="pd-captcha-php">
// Check user input is matches or not
// pdCaptchaCode() returns the generated captcha code in plain text
if ($userInput == pdCaptchaCode()){
// Captcha is correct
}If you want to pass your own word and height / width of the captcha image you may use this options (NOT recommended)
$config = [
'height' => 60,
'width' => 165,
'word' => 'PD27cap'
];
pdCaptchaCreate($config); Must keep captcha.php and font.ttf in the same directory
See the live use in the contact form of the website- latentsoft.com