PHP Tutorial

Define PHP

PHP Installation

PHP INI File

PHP Comment

PHP Case Sensitivity

PHP Variable, DataType

PHP Echo & Print

PHP Operators

PHP Receiving Input

Decision Making - if...else

PHP Switch Case

PHP Loops

PHP Jumping Statement

PHP Image Gallery

PHP File Upload

PHP Arrays

PHP Date Functions

PHP String Functions

PHP Math Functions

PHP Functions

PHP Variable Scope

PHP Constant Variable

PHP Superglobals

PHP Form Validation

PHP Include Statement

PHP Filter

PHP File Handling

PHP Cookies

PHP Session

PHP Send Emails

PHP Captcha

PHP MySQL Select

PHP MySQL Insert

PHP MySQL Delete

PHP MySQL Update

PHP MySQL Injection

PHP Assignment

Page Stats

Visitor: 287

PHP Captcha

CAPTCHA is a simple test to determine if a user is a computer or a human. It is used to prevent spam abuse on the websites. So if you use CAPTCHA on your web site forms, this can help in stopping some bots and making life harder for other bots in accessing or using your forms.
In brief the CAPTCHA protection works by generating a random string, writing it to an image, then storing the string inside a session or by some other method. This is then checked when the form is submitted.

File1.php

<style>
	.text{
		border:none;
		background:#963;
		letter-spacing:5px;
		width:70px;
		padding-left:5px;
		cursor:default;
	}
</style>

<?PHP
	$a = substr(str_shuffle("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"),0,5);
?>

<form action="file2.php">
	Enter id <input type="text" name="id"> <br>
    Enter pass <input type="text" name="pass"> <br>
    <input type="text" value="<?PHP echo $a;?>" name="a" readonly class="text" onmousedown="return false;"> 
    <input type="text" name="capcha"> <br>
    <input type="submit" name="submit">
</form>

file2.php

<?php
	$a=$_GET['a'];
	$id=$_GET['id'];
	$pass = $_GET['pass'];
	$cap =$_GET['capcha'];
	
	if(strtolower($cap)==strtolower($a)){
		echo "valid";
	}
	else
	{
		echo "Invalid";
	}
	
?>