Like this code?
Show the author your appreciation.
A CAPTCHA ( "Completely Automated Public Turing test to tell Computers and Humans Apart") is a type of challenge-response test used in computing to determine whether or not the user is human. A CAPTCHA involves one computer (a server) which asks a user to complete a test. While the computer is able to generate and grade the test, it is not able to solve the test on its own. Because computers are unable to solve the CAPTCHA, any user entering a correct solution is presumed to be human. A common type of CAPTCHA requires that the user type the letters of a distorted image, sometimes with the addition of an obscured sequence of letters or digits that appears on the screen.
This is the form.php
<?php
session_start ();
?>
<form name="form1" method="post" action="form.php">
<table border="1" width="380" align="center" cellspacing="2" cellpadding="0" bgcolor="#C1DBFF"><TR><TD>
<table bgcolor="" align="center">
<tr> <td align="center" colspan="2"><img src="http://192.168.0.6/workbench/lekha/test/captcha.php"></td><tr>
<td align="center"> Please enter the string shown in the image.</td><tr>
<td align="center"><input name="number" type="text"></td><tr>
<td align="center"><input name="Submit" type="submit" value="Submit"></td> </tr>
</table>
</TD></TR></table>
</form>
<div align="center">
<?php
if(isset( $_REQUEST [ 'Submit' ])){
$key = substr ( $_SESSION [ 'key' ], 0 , 5 );
$number = $_REQUEST [ 'number' ];
if( $number != $key ){
echo ' Validation string not valid! Please try again!' ;}
else{
echo ' Thank You for the verification!' ;}
}
?>
</div>
//Second file which is called in form.php-captcha.php
<?php
session_start ();
$md5 = md5 ( microtime () * mktime ());
$string = substr ( $md5 , 0 , 5 );
//echo $string;
//$string="bac12g";
$image = imagecreatefromjpeg ( "images/box5" );
$black = imagecolorallocate ( $image , 0 , 0 , 0 );
$line = imagecolorallocate ( $image , 233 , 239 , 239 );
$line2 = imagecolorallocate ( $image , 153 , 165 , 123 );
imageline ( $image , 10 , 1 , 30 , 25 , $line2 );
imageline ( $image , 1 , 60 , 40 , 10 , $line2 );
imageline ( $image , 5 , 8 , 20 , 20 , $line2 );
imageline ( $image , 6 , 40 , 20 , 15 , $line2 );
for ( $i = 0 ; $i <= 256 ; $i ++) {
$point_color = imagecolorallocate ( $image , rand ( 0 , 255 ), rand ( 0 , 255 ), rand ( 0 , 255 ));
imagesetpixel ( $image , rand ( 6 , 128 ), rand ( 2 , 38 ), $point_color );
}
$str_array =array();
$len = strlen ( $string );
for( $i = 0 ; $i < $len ; $i ++) $str_array []= $string { $i };
imagestring ( $image , 5 , rand ( 2 , 10 ), rand ( 2 , 11 ), $str_array [ 0 ], $black ); // Draw a random string horizontally
imagestring ( $image , 5 , rand ( 18 , 25 ), rand ( 2 , 11 ), $str_array [ 1 ], $black ); // Draw a random string horizontally
imagestring ( $image , 5 , rand ( 33 , 40 ), rand ( 2 , 11 ), $str_array [ 2 ], $black ); // Draw a random string horizontally
imagestring ( $image , 5 , rand ( 47 , 55 ), rand ( 2 , 11 ), $str_array [ 3 ], $black ); // Draw a random string horizontally
imagestring ( $image , 5 , rand ( 61 , 68 ), rand ( 2 , 11 ), $str_array [ 4 ], $black ); // Draw a random string horizontally
//imagestring($image, 5, 4, 13, $string, $black);
$_SESSION [ 'key' ] = $string ;
header ( "Content-type: image/jpeg" );
imagejpeg ( $image );
?>
A captcha image allows you to prevent spam posting when users reload the page and stop bots from submitting forms automatically. This version allows you to use your own fonts (.ttf) to show the text.
Categories : PHP , Security , Graphics , GD image library Securing Web Forms with Simple PHP-CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart)
Categories : PHP , Security , GD image library , Sessions Generate image with random number (CAPTCHA) Categories : PHP , GD image library , Graphics , Security A damaged image generator (class) for validating text.
CAPTCHA - Completely Automated Public Turing test to tell Computers and Humans Apart Categories : PHP , PHP Classes , Security , GD image library , Security PHP Image Compression using GD library Categories : PHP , Compression , GD image library , Graphics session out Timer Categories : PHP , Sessions , Security , Beginner Guides Line graphics generation library written in PHP + GD library (spanish comments) Categories : PHP , Graphics , GD image library a simple pie-chart in php3 (with gd) Categories : PHP , Graphics , GD image library , Charts and Graphs EasyPhpThumbnail Class - The EasyPhpThumbnail class allows you to generate thumbnails and handle image manipulation for GIF, JPG and PNG on-the-fly. Categories : PHP , PHP Classes , Object Oriented , Graphics , GD image library Display a bar chart based on random values. Categories : Graphics , PHP , GD image library , Charts and Graphs imageMarker v 3.00 with new advanced features Categories : PHP , PHP Classes , Graphics , GD image library Session Validation Methods (Security Checks) Categories : PHP , Sessions , Security Dynamic Image Authentication System in Signup Pages (CAPTCHA) Categories : PHP , Security , GD image library Function to generate readable/remeberable random password Categories : PHP , Security , Security crop and resize image class using gd library function Categories : PHP , PHP Classes , GD image library , Graphics
Bruce Borner wrote : 1690
img src="http://192.168.0.6/workbench/lekha/test/captcha.php"></
Can you specify the non-local address of the above?
Bruce Borner wrote : 1691
="http://192.168.0.6/workbench/lekha/test/captcha.php"></
There is no captcha.php ...
There is only form.php and form.php-captcha.php
form.php is looking for the image on 192.168.0.6