Location: PHPKode > scripts > tapcc ain't a php captcha class > tapcc-aint-a-php-captcha-class/example.php
<?
require("captcha.class.php");

if ($_POST['submit']!= 'send')
{
	$captcha=new Captcha;
	$captcha->load_ttf();
	$captcha->make_captcha();
	$captcha->delold();

	$filename=$captcha->filename;
	$privkey=$captcha->privkey;
	$qry="INSERT INTO `acc_creation_captcha`(filename, acc_creation_captcha.key) VALUES('".	$filename."','".$privkey."')";
	mysql_query($qry);
	?>
	<form action="?" method="post">
		<img src="<?=$filename?>" />
		<input type="hidden" name="filename" value="<?=$filename?>"
		<input type="text" name="key" />
		<input type="submit" name="submit" value="send" />
	</form>
	<?
}
else
{
	$filename=mysql_real_escape_string($_POST['filename']);
	$key=$_POST['key'];

	$correctkey=@mysql_result(mysql_query("SELECT acc_creation_captcha.key FROM acc_creation_captcha WHERE filename='$filename'"),0);

	if ($correctkey!=strtolower($key)|| $_POST['key']=="")
	{
		echo "Wrong key";
	}
	else
	{
		echo "Right key";
	}
}
Return current item: tapcc ain't a php captcha class