Simple captcha to prevent your guestbook or feedback form

captcha.php code:-

<?php
//Developed by: Dinangkur Kundu <dkundu@gmail.com>
//Version: 0.0.2
//Last revision Date: 15th February, 2007
//Company: Quantumcloud <http://www.quauntumcloud.com>

session_start(); //start session
header (”Content-type: image/png”); //define content type

$text = rand(100,999);

$_SESSION[”v_code”] = $text;

$height = 25; //height of the image
$width = 35; //width of the image

//create image
$image = imagecreate($width, $height) or die(”Cannot Initialize new GD stream”);
//define background color of the image
$background_color = imagecolorallocate($image, 255, 255, 255);
//define text color in the image
$text_color = imagecolorallocate($image, 233, 14, 91);
//Draw a string horizontally
imagestring($image, 5, 5, 3, $text, $text_color);
//Output a PNG image to either the browser or a file
imagepng($image);
//Destroy the image
imagedestroy($image);
?>
test.php code:-

<?php
session_start();
//if form not submit skip
if ($submit == “Submit”) {
if ($_POST[”v_code”] != $_SESSION[”v_code”] OR $_SESSION[”vercode”]==”) {
echo ‘<strong>Incorrect verification code.</strong><br>’;
} else {
echo ‘<strong>Verification successful.</strong><br>’;
};
}
?>
<form method=”post” action=”test.php”>
<div>Name:</div>
<input type=”text” name=”txt_name” />
<div>Enter Code:</div>
<input type=”text” name=”v_code” />
<div><img src=”captcha.php” /></div>
<input type=”submit” name=”submit” value=”Submit” />
</form>

Put both file in same directory and run test.php in your browser.


Whether you want to know how to make simple captcha to prevent your guestbook or feedback form or you want to do some courses; now there are many ways through which you can learn online. Microsoft has opened new ways of online learning. If you are wireless internet provider and want to know about voice over IP (CVOICE) then 642-432 course is really very good for your career. In order to secure your networks with PIX and ASA then opt for 642-523 course. If you are interested in implementing Microsoft Exchange Server then 70-284 course is the right choice for you. For net work administrator who has to support users and troubleshoot the desktop applications 70-272 course is specially design for them. 70-620 course is design for Microsoft Windows vista, configuring. A smart business communication system for engineers 650-178 course is really very good. You can opt for many other courses like 646-203 or 1Y0-259 but it all depends upon your interest.


About this entry