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 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 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 Create Thumbnails - resize an image - jpeg, jpg, gif, png to the specifed width and height in proportion without loosing out on pixcel quality. Categories : PHP , GD image library , Graphics Creates a CAPTCHA image in PHP, which displays 5 numbers stored in a session. Categories : PHP , GD image library , Form Processing , Security Create a Thumbnail Using PHP, GD and Exif Categories : PHP , Graphics , Exif , GD image library Authenticator for Exchange Server LDAP Categories : PHP , Authentication , LDAP , Security , Sessions A login page that require username, password and userlevel. Categories : PHP , Security , Sessions , MySQL , Databases PHP Email image generator - hide your email from bots - using the GD Library Categories : PHP , Graphics , GD image library , Beginner Guides Advanced Image WaterMarker Categories : PHP , PHP Classes , GD image library , Graphics , Object Oriented Image Generation Class ( PNG Format ) Categories : PHP , GD image library , PHP Classes , Graphics A simple PHP login script that you can modify to suite your needs. It use a session to store data in a session file submited by the page. Categories : PHP , Sessions , Security , Authentication Simple PHP Bar Graph using GD library Categories : PHP , GD image library , Graphics , Arrays PHP Image Compression using GD library Categories : PHP , Compression , 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