Location: PHPKode > scripts > caText n caMath > catext-n-camath/ca_demo.php
<?php

	include('catext.class.php');
	include('camath.class.php');

	/***** FORM HANDLE *****/	
	echo "<h2><font color=\"red\">";
	if(isset($_POST[submit_ctext])){
		if(md5(trim($_POST[code])) == trim($_POST[code_ori]))
			echo "Code accepted..";
		else 
			echo "Code False!!!";		
	}

	if(isset($_POST[submit_cmath])){
		// use proper encryption function
		if(md5(trim($_POST[code])) == trim($_POST[code_ori]))
			echo "Code accepted..";
		else 
			echo "Code False!!!";
		
	}
	echo "</font></h2>";
	/***** END FORM HANDLE *****/	

	// create
	$cText = new catext;
	$cMath= new camath;

?>

		
	<h3>Example for caText and caMath class with md5 encryption..</h3>
	<p>This class used for preventing robot or non human to posting via form.
	I don't like use captcha because i usually disabled displaying image on my browser setting.
	So I build this class :).</p>
	
	<p>For general purpose, this class can protect your web form. 
	But, i think this class is easier to break than real captcha.. so used it at your own risk.</p>
	
	
	<br><br>
	<b># <u> caText example:</u></b>
	<br /><br />

	<form method=post action="">
	<input type="text" name="name"> Name<br>
	<textarea name="comment" rows="5" cols="30">your comment here..</textarea>
	<br>
	<?php $cText->generate(); ?> <input type="text" name="code" size="5">
	<input type="hidden" name="code_ori" value="<? echo md5($cText->get_key());?>">
	<br>
	<input type="submit" name="submit_ctext">
	</form>
	
	<br>
	<b># <u>caMath example:</u></b>
	<br /><br />
	
	<form method=post action="">
	<input type="text" name="name"> Name<br>
	<textarea name="comment" rows="5" cols="30">your comment here..</textarea>
	<br>
	<?php $key_ori = $cMath->generate('md5'); ?> <input type="text" name="code" size="5">
	<input type="hidden" name="code_ori" value="<? echo $key_ori;?>">
	<br>
	<input type="submit" name="submit_cmath">
	</form> 

	<br>
	&copy; deepforest [colique at gmail.com]
Return current item: caText n caMath