Location: PHPKode > scripts > CAPTCHA by Anchal > captcha-by-anchal/example.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<TITLE>Captcha Class </TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
</head>
<body>
<?PHP
require_once('captcha.config.php');
require_once('captcha.class.php');

	//Initialize the captcha object with our configuration options
	$captcha =& new captcha($CAPTCHA_CONFIG);
	if (isset($_POST['image'])) {
		switch($captcha->validate_submit($_POST['image'],$_POST['attempt']))
		{
	
			// form was submitted with incorrect key
			case 0:
				echo "<script>alert('Invalid Code');</script>";
				echo '<p><br>Sorry. Your code was incorrect.';
				echo '<br><br><a href="'.$_SERVER['PHP_SELF'].'">Try AGAIN</a></p>';
				break;

			// form was submitted and has valid key
			case 1:
				echo '<p><br>Congratulations. You will get the resource now.';
				echo '<br><br><a href="'.$_SERVER['PHP_SELF'].'">Test Again</a></p>';
				break;			
		}
	}
	else {
	$imgLoc = $captcha->create_captcha();
	?>
	<img src="<?php echo $imgLoc;?>" alt="This is a captcha-picture. It is used to prevent mass-access by robots." title=""><br>
	<form name="captcha" action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
	<input type="hidden" name="image" value="<?php echo $imgLoc;?>">
	<input type="text" name="attempt" id="attempt" value="" size="20"><br>
	<input type="submit" value="Submit">
	</form>
	<?php
    }
?>
</body>
</html>
Return current item: CAPTCHA by Anchal