Login   Register  
PHP Classes
elePHPant
Icontem

File: form.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of musthafa  >  Customizable CAPTCHA  >  form.php  >  Download  
File: form.php
Role: Example script
Content type: text/plain
Description: captcha demo page
Class: Customizable CAPTCHA
Generate and validate CAPTCHA images
Author: By
Last change: no change
Date: 3 years ago
Size: 991 bytes
 

Contents

Class file image Download
<?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>