Archive for October, 2009

Security Code Verification Using PHP

Security code Verification is used for security test to determine whether or not the user is human. Here is a simple security code Verification Script that Generate the code Dynamically.

<?php
$im = ImageCreate(120, 30);  //create image
$white = ImageColorAllocate($im, 255, 255, 255);  //Allocate color for  image
$black = ImageColorAllocate($im, 50, 50, 50);
$string = md5(rand(0,9999));  //Generate a random value and Calculate the md5 hash of the string
//echo $string;
$string=substr($string,1,7); //Return part of a string
$verification = $string;
ImageFill($im, 0, 0, $black); //Fill the Image
ImageString($im, 5, 30, 10, $verification, $white); //Draw the string
Imagejpeg($im, “verify.png”); //Create the Image as ‘png’ format
ImageDestroy($im);  //Destroy the image
?>
<form method=”post” action=”image_verification.php”>
<input type=’hidden’ name=’secretcode’ value=’<?=$verification?>’>
Type Code from Image:
<input type=’text’ name=’code’>
<img src=’verify.png’ border=’1′>
<input type=’submit’ name=’submit’ value=’Submit’>
</form>

<?php
if(isset($_POST['submit']))
{
$code = $_POST['code'];
$secretcode = $_POST['secretcode'];

if($code!=$secretcode){
print “<font color=’red’>Verification failed</font>”;
}
else{
print “<font color=’green’>Verification Success</font>”;
}
}
?>

Add comment October 29, 2009


My Fav




My twiTTer

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

Top Clicks

 

October 2009
M T W T F S S
« Jun   Dec »
 1234
567891011
12131415161718
19202122232425
262728293031  

Archives

Category Cloud

JAVA Java Script MySQL Networking(CISCO) PHP Template Uncategorized

Recent Comments

Rony Parvej on About
Zaman on Connecting MySql With Jav…
Rahul on Connecting MySql With Jav…
pollobcse05 on About
মাহমুদ ফয়সাল on About

Blogroll

Meta

My Flickr Photos

SDC12881

SDC12818

SDC12808

SDC12802

SDC12794

More Photos

Pages

Blogroll

Meta