Captcha PHP: script example

Table of contents:

Captcha PHP: script example
Captcha PHP: script example

Captcha PHP is a program used to verify that a human, and not a computer, is entering data. Captchas are usually displayed at the end of online forms and ask the user to enter text with a distorted image. The text in the image can be masked by distorted font, wave and zigzag lines, and the automatic recognition program cannot detect it. Some PHP Captchas include an audio pronunciation feature. Captcha tests can stop 90% of hacker attacks by blocking robot software and limiting online requests.

captcha php
captcha php


Captcha PHP is a call response system designed to differentiate between humans and robotic programs. Captchas are used as security checks to prevent spammers and hackers from using forms on web pages to insert malicious code.


Captcha is a type of security measure known as challenge-response authentication. This solution helps protect the user from spam and password decryption by asking them to perform a simple test that proves that it is a person and not a computer trying to break into a password-protected account.

A captcha test consists of two simple parts: a random sequence of letters or numbers that are displayed as a distorted image, and a text field. To take the test and prove your human identity, simply enter the characters you see in the image into the text field.


The need for Captcha PHP was born back in 1997. At the time, the AltaVista search engine was looking for a way to block automatic URL placement on a platform that misrepresented the search engine's ranking algorithms. To solve this problem, Andrey Broder, AltaVista's chief scientist, developed an algorithm that randomly generated an image of printed text. Although computers could not recognize the image, people could read a message containing the image and respond accordingly. Brodeur and his team received a patent for this technology in April 2001.

plugins captcha recaptcha recaptcha php
plugins captcha recaptcha recaptcha php

In 2003 Nicholas Hopper, Manuel Bloom, Louis von Ahn of Carnegie Mellon University and John Langford of IBM developed an algorithm and coined the term Captcha. The name stands for a completely automated Turing test of public use for differentiating between people and machines.


PHP is a freely available scripting language and interpreter used primarily on Linux web servers. PHP runs on the server and a comparable JavaScript alternative runs on the client. This programming language is an alternative to Microsoft Active Server Page (ASP) technology. Like ASP, the Captcha PHP script is embedded into the web page along with the HTML code. Before sending the page to the user, the web server calls PHP to interpret and perform the operations called in the script.

An HTML page containing a PHP script is usually given a.php filename suffix - ".php7" or ".phtml". PHP can be thought of as "dynamic HTML pages" since the content will depend on the results of the script's interpretation.

The language is free and used under an open source license.

Most of the syntax is borrowed from other languages, but PHP has a number of unique and special features, such as. PHP is great for creating database driven websites.

google captcha php
google captcha php

How Captcha works in PHP

Captcha is a kind of Turing test. The bottom line is that end users are asked to perform some tasks that a software bot cannot perform. Tests are often associated with JPEG or-g.webp


The most common type is text, which requires the user to view a garbled string of alphanumeric characters in an image and enter the characters in the attached form. Captcha text can also be broadcast in MP3 audio to meet the needs of the visually impaired. As with images, bots can detect the presence of an audio file, but only a human can hear and recognize the information contained in the file.

Image Recognition Captcha in PHP, which is also widely used, asks users to identify a subset of pictures in a large set of images. For example, the user might be presented with a set of icons and prompted to click on all those that have cars in them.

Other Captcha types include:

  • Math Captcha - Requires the user to solve a basic math problem, such as adding or subtracting two numbers.
  • 3D Super Captcha - here the user must identify the image displayed in 3D.
  • I'm Not a Robot - in this type of captcha the user must check the box.
  • Marketing - Requires the user to enter a specific word or phrase related to the sponsor's brand.

Captcha Bypass: Latest Extensions Review

Users can use extensions from browser add-ons that allow users to bypass captcha input. Popular browser add-ons include AntiCapture, Captcha Be Gone and Rumola.

php image captcha
php image captcha

Automatic AntiCaptcha plugin for Chrome and Firefox automatically finds plugins captcha recaptcha recaptcha php on a web page and renders it for the user. The app is not free: at the time of this writing, the service starts at $0.70 for 1,000 Captcha images. The Captcha Be Gone extension detects captcha on web pages, processes it and copies the result to the user's clipboard. The utility is currently available for Firefox, Chrome, and Internet Explorer for a $3.50 per month subscription.

The Rumola app for Firefox, Chrome and Safari automatically searches for Captcha on web pages that the user visits. Currently the cost is $0.95 for 50 captcha images or $1.95 for 150 solutions. This developer also has a JavaScript bookmarklet that can be used for devices that connect to the Internet.

Because captcha bypass add-ons are created by third parties, end users should be aware that the browser extension may show browsing activity to untrusted sources and expose user data to the risk of compromise. Another reason not to use a captcha bypass is that the performance of the extensions and the level of captcha creation are incompatible. This is primarily due to the fact that as bots get smarter, captcha generation techniques also evolve and installed plugins can no longer do their job.

plugins captcha recaptcharecaptcha php how to open
plugins captcha recaptcharecaptcha php how to open

How to open PHP Captcha: Example

The code below shows how to create a simple Captcha graphic with random strings and numbers and how to include it in an HTML form to prevent malicious scripts from being automatically submitted. It will also help answer the question: how to open plugins captcha recaptcha recaptcha php?

The following code needs to be saved as a separate PHP file (we call it Captcha /php). This file creates a-p.webp

Captcha PHP script example


//google Captcha PHP PHP image Captcha

// Adapted for The Art of Web:

// Please acknowledge use of this code by including this header.


The result of this script looks like a picture with a random selection of numerical values that the user must enter in the input field.

The image obtained as a result of processing the script (Captcha PHP ajax) should be difficult for "robots", but as simple as possible for people. If you wish, you can add complexity to the graphics by adding colors or textures, or using different fonts and a rotation effect.

captcha php example
captcha php example

Alternative schemes

Due to the fact that captchas based on text distortion are vulnerable to attacks, some researchers have proposed alternative solutions, includingimage recognition, which require users to identify simple objects in pictures. The argument in favor of these schemes is that object recognition tasks are more difficult to perform than text recognition, therefore, this category of captchas is more resistant to attacks. Here are some of the notable alternative patterns:

  • Chew published its work at the 7th International Conference on Information Security ISC'04, proposing three different versions of captcha pattern recognition, and confirmed this hypothesis through user research.
  • Datta published their work at ACM Multimedia '05, titled IMAGINATION, proposing a systematic way to recognize Captcha images. Images are distorted in such a way that modern image recognition approaches (which are potential attack technologies) do not recognize them.
  • Engineers at IT giant Microsoft (Jeremy Elson, John R. Duzer, John Howell, and Jared Saul) have developed the Animal Species Image Recognition for Access Restriction (ASIRRA), which asks users to distinguish between cats and dogs. Microsoft had a beta version of this solution for use by websites. Tests showed that people successfully recognized images 99.6% of the time in 30 seconds. This solution was described in a 2007 paper to the Proceedings of the 14th ACM Conference on Computer and Communications Security (CCS).

What is the difference between Captcha and reCaptcha?

Captcha is an identity test (usuallyblurry letters that need to be deciphered) used by many sites to prevent spam.

ReCaptcha is a reverse Captcha. The same test that is used not only to prevent spam, but also to help with the digital publishing project. In other words, Recaptcha quizzes aren't just random combinations of words, but excerpts from books, while Captcha uses multiple identity verification methods, including math or general questions, visual puzzles, and chess puzzles.

ReCaptcha is currently the most popular implementation.

captcha php script
captcha php script


Although captcha is not an unconditional authentication tool, its use can be very effective in the following cases:

  • Enumerations (registration or password reset forms are often vulnerable to malicious attacks - without Captcha, a hacker can obtain valid usernames, phone numbers, or any other sensitive information in a short time).
  • Automatically send many GET/POST requests in a short amount of time when not desired (e.g. receiving SMS/MMS/email). In this case, Captcha provides a rate limiting feature.
  • Automatically create an account that should only be used by humans (eg, create email accounts, stop spam).
  • Auto posting to blogs, forums and wikis.
  • Any auto attacks that en masse receive ormisusing sensitive information from the app.

Using Captcha as protection against cross-site request forgery is not recommended as there are stronger countermeasures.

Popular topic

Editor's choice

  • Windows 7 password bypass: possible methods and recommendations from experts
    Windows 7 password bypass: possible methods and recommendations from experts

    The fact that users (most often computer administrators) protect Windows operating systems from unauthorized use, for example, in their absence at the computer, does not surprise anyone. However, often the administrator may not give the registered user enough rights to perform any actions or set personal settings, and therefore it may be necessary to log in with an administrator registration

  • How to remove a virus from a flash drive without losing data?
    How to remove a virus from a flash drive without losing data?

    Removable USB storage devices in the form of the most common flash drives are susceptible to viruses no less than hard drives with operating systems installed on them. And it is often quite problematic to identify the presence of such a threat or neutralize it. How to remove a virus from a flash drive and restore files (hidden or infected) will be discussed further

  • File viruses are computer code to achieve goals bypassing security systems
    File viruses are computer code to achieve goals bypassing security systems

    File viruses are computer code to achieve goals bypassing security systems. This is what inspired people to create antiviruses, what allows hackers to learn and steal millions of dollars every day

  • PC prevention for stable operation - expert advice. Computer help
    PC prevention for stable operation - expert advice. Computer help

    The fact that almost all modern computer systems require constant care, apparently, all users know. But not everyone has a clear enough idea of what this should manifest itself in. To keep the computer, operating system and installed applications in the most efficient condition, it is necessary to carry out preventive maintenance of the PC software and monitor the hardware components (installed equipment)

  • Detector software: what is it in the field of anti-virus protection?
    Detector software: what is it in the field of anti-virus protection?

    Apparently, many users of modern computer systems have heard or know that there are so-called detector programs. What they are is easy to understand if you just turn to the translation or interpretation of the English word detect, which literally means “to detect”