Login   Register  
PHP Classes
elePHPant
Icontem

File: example-color.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Nguyen Duc Thuan  >  Named Buttons Captcha  >  example-color.php  >  Download  
File: example-color.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Named Buttons Captcha
Show a CAPTCHA image with validation questions
Author: By
Last change:
Date: 2012-03-27 19:14
Size: 1,196 bytes
 

Contents

Class file image Download
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <form method="post"><div>
                <?php
                
require 'lib/NamedButtonsCaptcha.php';

                
$captcha = new NamedButtonsCaptcha();
                
$captcha->setKeyStorage(new NamedButtonsCaptcha_KeyStorage_Session())
                    ->
setBackgroundColor(array(250250250))
                    ->
setFontColor(array(00255));
                
                if (
'POST' === $_SERVER['REQUEST_METHOD']) {
                    
$values = isset($_POST['nbc']) ? $_POST['nbc'] : array();
                    
                    if (
$captcha->isValid($values)) {
                        echo 
'<div style="color:green">Verification succeeded</div>';
                    } else {
                        echo 
'<div style="color:red">Verification failed</div>';
                    }
                }

                
$captcha->render();
                
?>
                <br />
                <br />
                <input type="submit" value="Verify" />
            </div></form>
    </body>
</html>