CAPTCHA – human authentication on a form

Recently I started to get a lot of junk in my in-box through the contact form. This was all generated by spam bots on the net so I added in the new feature of human evaluation by use of the image with a number on the contact and comment forms to slow the junk entering […]

Recently I started to get a lot of junk in my in-box through the contact form. This was all generated by spam bots on the net so I added in the new feature of human evaluation by use of the image with a number on the contact and comment forms to slow the junk entering my in-box. This technique is known as CAPTCHA (Completely Automated Public Turing to tell Computers from Humans Apart).

A CAPTCHA test is a program that can generate and grade tests that most humans can pass and current computer programs can’t pass.

So this particular one is written with PHP and GD (image manipulation part of PHP).

The first part of this is to get a suitably random number and store it somewhere. I have used a session variable so that I can reuse the random function.

Generating the image using that number looks like this, I have saved this in a PHP file and we will look at how to call this in a minute. The code comments should be explanation enough on how it works.

Now because we put the random number in the user Session, it makes it really easy to get a hold of it on processing the form.

Duncan Isaksen-Loxton

Educated as a web developer, with over 20 years of internet based work and experience, Duncan is a Google Workspace Certified Collaboration Engineer and a WordPress expert.
Login
Log in below to access your courses.
Log In With Google
Forgot Password
Enter your email address or username and we’ll send you instructions to reset your password.