Click here to get download URL
With the surge of spam bots which annoys site admins with fake registrations and contact us form registrations,Captcha has become inevitable for all sites having registration/signup form and/or contact us form.Captcha is the abbreviation of 'Completely Automated Public Turing test to tell Computers and Humans Apart'.Having been in web development for quite a long time we understood that spam posts are one of the most annoying issues site admins had to face.Taking this into consideration we decided to develop a simple but elegant captcha with multiple options.P
Presenting OSOLMultiCaptcha a free captcha class in PHP that could be easily integrated in any html forms.It comes with multiple configurable options.
Available options are:
- Background color
- Text color
- Noise in Background
- Noise in Text
Additional functions(ttf/otf files must be saved in utils/ttfs folder to use the following options) - Allowed symbols(characters)
- Font
- Letter Size
You can preview the captcha with different settings by hovering mouse over "Hover Mouse here to preview Captcha with entered settings" text
Once you hover ,the url of the currently previewed captcha will be written below it.So you could copy it to use it as captcha image source
At any time you could also test how the captcha works with the current settings by clicking "Test Captcha with current settings" linkPS:inorder to use options 5 to 8(Letter Type (Plane or distorted),Allowed symbols(characters),Font,Letter Size),If you are downloading from phpclasses.org, you should manuallly add atleast one TTF/OTF File in the utils/ttfs folder before you open previewCaptcha.php in browser
Demo code to add captcha to form
1 2 3 4 5 6 |
<form action="" method="post"> <p>Enter text shown below:</p> <p><img src="/displayCaptcha.php"></p> <p><input type="text" name="keystring"></p> <p><input type="submit" value="Check"></p> </form> |
Demo code to display Captcha
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<?php session_start(); require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'OSOLmulticaptcha.php'); $captcha = new OSOLmulticaptcha(); $captcha->imageFunction = 'create_imageAdv';// or 'create_imagePlane' $captcha->font_size = 36; $captcha->font_ttf = $captcha->fontPNGLocation.'/ttfs/AdLibBT.TTF'; $captcha->bgColor = "#2c8007"; $captcha->textColor = "#ffffff"; $captcha->symbolsToUse = "ABCDEFGHJKLMNPQRTWXY346789";//avoid confusing letters like i , I , 1 and 2,z,Z etc $captcha->white_noise_density = 0;//noise in bg $captcha->black_noise_density = 0;//noise in text $captcha->displayCaptcha(); $_SESSION['OSOLmulticaptcha_keystring'] = $captcha->keystring; ?> |
Demo code to verify Captcha
1 2 3 4 5 6 7 8 9 10 11 |
<?php session_start(); if(count($_POST)>0){ if(isset($_SESSION['OSOLmulticaptcha_keystring']) && $_SESSION['OSOLmulticaptcha_keystring'] === $_POST['keystring']){ echo "Correct"; }else{ echo "Wrong"; } } unset($_SESSION['OSOLmulticaptcha_keystring']); ?> |
Download Captcha only for HTML forms from github : https://github.com/osolgithub/OSOLMulticaptcha.git
Download Wordpress plugin :http://wordpress.org/plugins/customizable-captcha-and-contact-us-form/
|
|