PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Cristian Navalici   CAPTCHA 2   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Testsuit
Class: CAPTCHA 2
Generate CAPTCHA validation images
Author: By
Last change: Updated version.
Date: 17 years ago
Size: 1,089 bytes
 

Contents

Class file image Download
<?php
/*

EXAMPLE FILE FOR CAPTCHA2 CLASS
ver 0.9

*/

require ('captcha.class.php');
$ob = new Captcha();

if (isset (
$_POST['guess'])) {
   
$txtguess = $_POST['txtGuess'];
   
// this way you can do the verification
   
if ($ob->verifyCaptcha($txtguess))
        echo
"<br />These are identical";
    else
        echo
"<br />Opps! Try again";
}

// create a default captcha (6, 'png', true)
$ob->createCaptcha();

// create a captcha (png format with lines display and with length of 6)
// $ob->createCaptcha(6, 'png', true);

// create a captcha (jpeg format with lines display and with length of 10)
// $ob->createCaptcha(10, 'jpeg', true);

// create a captcha (png format without lines display and with length of 6)
// $ob->createCaptcha(6, 'png', false);

?>
<html>
<head></head>

<body>
<br />
<!-- display the captcha previously generated-->
<?php echo $ob->showCaptcha(); ?>

<form method="post" action="example.php">
    <input type="text" name="txtGuess" id="txtGuess">
    <input type="submit" value="Verify" name="guess">
</form>

</body>


</html>