Register Now


Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

PHP Human Test script

PHP Human Test script

PHP Human Test script in PHP could refer to a system that is designed to determine whether a user is a real person or a computer program (i.e. a “bot”). There are a few different ways to implement such a system, but one common approach is to use a “CAPTCHA” (Completely Automated Public Turing test to tell Computers and Humans Apart) challenge. A CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) is a type of challenge-response test used to determine whether a user is a real person or a computer program (i.e. a “bot”). The idea behind a CAPTCHA is to present the user with a task that is easy for a human to complete, but difficult for a computer.

One common type of CAPTCHA is an image containing distorted text. The user is asked to enter the text they see in the image into a form field. Since optical character recognition (OCR) technology is not advanced enough to accurately recognize distorted text, a computer program would have a hard time solving the challenge. However, humans can easily read the text and enter it into the form field.

Another type of CAPTCHA is a simple math problem or a question that requires logical reasoning. These tasks can be difficult for a computer program to solve but easy for a human.

CAPTCHA is used to prevent bots from automating certain actions such as creating fake accounts, spamming, or scraping sensitive data. By requiring users to prove they are human, CAPTCHA helps protect websites and online services from these types of malicious activity. It’s important to note that CAPTCHA is not 100% foolproof, as new technologies and techniques are constantly being developed to bypass it. However, it still remains one of the most effective ways of fighting against bots.

Simple PHP Human Test script with CAPTCHA system:


// Generate a random text string for the CAPTCHA
$_SESSION['captcha_text'] = generateRandomString();

// Create an image containing the text
$img = createCaptchaImage($_SESSION['captcha_text']);

// Send the image to the browser
header('Content-type: image/png');

// Function to generate a random text string
function generateRandomString() {
    $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    $string = '';
    for ($i = 0; $i < 5; $i++) {
        $string .= $characters[rand(0, strlen($characters) - 1)];
    return $string;

// Function to create an image containing the text
function createCaptchaImage($text) {
    // Create an image with a white background
    $img = imagecreatetruecolor(200, 50);
    $bg = imagecolorallocate($img, 255, 255, 255);
    imagefilledrectangle($img, 0, 0, 200, 50, $bg);
    // Add the text to the image
    $text_color = imagecolorallocate($img, 0, 0, 0);
    imagestring($img, 5, 70, 15, $text, $text_color);
    return $img;

This script generates a random text string, creates an image containing that text, and sends the image to the browser. When a user submits a form, the entered text is compared with the text stored in the session to determine if the user is human or a bot.

It’s important to note that this is a very basic example, and a real-world implementation would need to take into account security and accessibility concerns. Additionally, there are other methods to determine if a user is human or a bot, such as using reCAPTCHA by Google or hCaptcha.

Leave a reply