February 12, 2014 10:19 am

How to create Image less CAPTCHA using PHP

We all using old and traditional image captcha to to confirm that the user sending data is a human or a machine but to create that image captcha we have to create images for each page which takes few seconds to load the page. People don’t understand your captcha image reload the image, so now I am going to show you an alternate of image captcha is image less captcha with PHP where it generates the number as a phrase and ask user to type it in numbers.

create Image less CAPTCHA with PHP

We have used a PHP class ( imagelessCaptcha.php ) to perform this task let see how to use that class and make it working. We included a demo and source code to download.

Also Read: How to create CAPTCHA image verification in PHP and jQuery

 PHP Code

In this code we include imagelessCaptcha class and get a phrase of numbers with actual number and store actual number in session to verify input on form submission.

Show the phrase on your forms to prevent spamming on your websites.

HTML Form

This markup shows an input box and a phrase like: What is two-hundred and ninety-six point seven written as a number? you have to write it in numbers in input area and submit.

All together complete HTML,CSS and PHP

This is the complete code to implement in your web projects.

I hope it helps you so please feel free to give us your suggestions and improvements in comments below for our upcoming tutorials.

Author Huzoor Bux

I am Huzoor Bux from Karachi (Pakistan). I have been working as a PHP Developer from last 5+ years, and its my passion to learn new things and implement them as a practice. Basically I am a PHP developer but now days exploring more in HTML5, CSS and jQuery libraries.


Tutorial Categories:
  • Frank

    Hello there, this is a nice little script you got here. I’ve taken this and tried to implement it into my register page but i have one strange error. I have a validation class that does all my validation. When i submit the registration form $number is never equal to $_SESSION[‘correctNumber’] because when i echo out the $_SESSION variable it always renew when i hit the submit button. Therefore the correctNumber is always the one being displayed. How do I fix this? I’ve even tried with changing the superglobal to $_COOKIE with no luck 🙁 Best regards. Frank

    • huzoorbux

      Please check code creator file might be run 2 times check this again and please share your website link if its possible.

      • Frank

        Hello again. Thanks for the quick answer. Hmm.. i use a singleton pattern to get all my classes, maybe that has something to do with it? I dont know..it seems strange. Will try to load the class manually to see if the same thing happens then. I don’t think it runs two times tho. Is there anyway i can PM you the website link?

  • O’Sayo Michael Makinwa

    Really nice and helpful tutorial Huzoor

  • Ramesh Singh

    hi your code is working thanks for this..i want to make a refresh refresh button for this?

  • Razor Mureithi

    thax works perfectly

  • Michael Shaba

    Hello Good day , and i am a beginner in php, but sorry to stree u please , i am working on an online application form as a project using PFBC predefined class. i have been able to build or instantiate the class but i can not print to screen the result when a user fill the form, on submission. please would need your assistance.

  • Rahul

    we need image captcha like this one its urgent.
    pls help us

  • Rahul

    we need image captcha like this one its urgent.
    pls help us

  • Rahul

    we need image captcha like this one its urgent.
    pls help us