WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : CAPTCHA[Image verification]
Categories : PHP, Security, GD image library, Graphics, Sessions Click here to Update Your Picture
Suzzane Bruce
Date : May 07th 2007
Grade : 3 of 5 (graded 2 times)
Viewed : 5397
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Suzzane Bruce
Action : Grade This Code Example
Tools : My Examples List

 
Like this code?
Show the author your appreciation.
Submit your own code examples 
 

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);
?>



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
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
Simple class that uses GD to draw pie charts. After the class definition there's some sample code to demonstrate how you use the class.
Categories : Graphics, PHP, PHP Classes, GD image library, Charts and Graphs
Form Security - Match A Value For Success
Categories : PHP, Authentication, HTML and PHP, Sessions, Security
PHP Image Compression using GD library
Categories : PHP, Compression, GD image library, Graphics
Line graphics generation library written in PHP + GD library (spanish comments)
Categories : PHP, Graphics, GD image library
imageMarker v 3.00 with new advanced features
Categories : PHP, PHP Classes, Graphics, GD image library
crop and resize image class using gd library function
Categories : PHP, PHP Classes, GD image library, Graphics
session out Timer
Categories : PHP, Sessions, Security, Beginner Guides
PHP Email image generator - hide your email from bots - using the GD Library
Categories : PHP, Graphics, GD image library, Beginner Guides
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
Dynamic Image Authentication System in Signup Pages (CAPTCHA)
Categories : PHP, Security, GD image library
 Bruce Borner wrote : 1690
img src="http://192.168.0.6/workbench/lekha/test/captcha.php"&gt;&lt;/

Can you specify the non-local address of the above?
 
 Bruce Borner wrote :1691
="http://192.168.0.6/workbench/lekha/test/captcha.php"&gt;&lt;/

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