Sign in to follow this  
Cyber

Captcha Image Verification

Recommended Posts


A good way to avoid automatic form submissions when creating a web form is to add some kind of verification. One of the best ways is to use an image verification, called also captcha. What it does is to dynamically create an image with a random string displayed on it. Then visitor is asked to type that string in a text field and once the form is submitted it checks if the string on the image matches the one inputted by the user. Because there is no easy way to read a text from an image (image recognition) this is a good way to protect your web forms from spammers.
For doing this CAPTCHA I would suggest using a session variable where you store the string generated and displayed on that dynamically generated image.

For Established Members Only. Check this link for more info https://phcyber.com/topic/1703-phcyber-ranking/



Save this code in a file called captcha.php. What this script does is to generate a random number from 10000 to 99999 and then assign it to $_SESSION['vercode']. Then it generates a 25x65 pixels image with black background and white text using size 14. So if you upload that captcha.php file on your web site and open

For Members Only. Check this link for more info https://phcyber.com/topic/1703-phcyber-ranking/
you will see an image displaying random integer. You will receive a new random integer every time you refresh that page.

Next we need to create our web form.

For Established Members Only. Check this link for more info https://phcyber.com/topic/1703-phcyber-ranking/



Above code will create a form with a single textarea box, randomly generated image using the captcha.php script and a text field where you will have to enter the verification code.

All we have to do now is to make the submit.php script which will check if the verification code you enter matches the one that has been randomly generated.

For Established Members Only. Check this link for more info https://phcyber.com/topic/1703-phcyber-ranking/

 

  • Heart 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this