<?php
session_start(); // captcha class uses session to hold captcha code
include "class.captcha.php";
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) { /* post is used for submitting form */
// captcha verification code
if( Captcha::isValid($_POST['captcha']) )
echo "<h1>Valid</h1>";
else
echo "<h1>Verification failed!</h1>";
echo "<a href='index.php'> Try again </a>";
exit();
}
?>
<html>
<body>
<form action="" method="post">
<br />
<b>Note : </b> Set a ttf font before taking demo refer getcaptcha.php. use setFont() or place a font file in current dir [ rename it to captcha.ttf ] <br /> <br />
<!-- load the captcha image -->
<img src="getcaptcha.php" width="100" height="40" /> <br />
<!-- use same image size as you used in Captcha::setSize() method. -->
Enter the letters as shown in the image above<br /> <br /> <input type="text" name="captcha" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
|