PHP Classes

File: examples/ascii-captcha.php

Recommend this page to a friend!
  Classes of sameer shelavale  >  PHP Multi CAPTCHA  >  examples/ascii-captcha.php  >  Download  
File: examples/ascii-captcha.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Multi CAPTCHA
Perform CAPTCHA validation with multiple solutions
Author: By
Last change: fixed the include filename in examples.
Date: 6 years ago
Size: 1,074 bytes
 

Contents

Class file image Download
<?php

include_once( "../src/Captcha.php");


$captcha = new \MultiCaptcha\Captcha([
   
'secret'=> "form1-secret-key",
   
'options' => [
       
'ascii' => [
           
'maxCodeLength' => 8,
           
'fonts'=>array(
               
'banner' => 4, //render with font size 4px or it becomes too big
               
'doom' => 5, //render with font size 8px
               
'small' =>8 //render with font size 8px, "small" font is at src/types/ascii/fonts/small.flf
           
)
        ]
    ],
   
'refreshUrl'=>'ascii-captcha.php?captcha=refresh',
   
'helpUrl'=>'http://github.com/sameer-shelavale/multi-captcha'
] );

if( isset(
$_GET['captcha']) && $_GET['captcha'] == 'refresh' ){
    echo
$captcha->refresh();
    exit;
}elseif( isset(
$_REQUEST['submit'] ) ){
    if(
$captcha->validate( $_POST, $_SERVER['REMOTE_ADDR'] ) ) {
        echo
"Correct.";
    }else{
        echo
"Wrong: ". $captcha->error;
    }
}
?>

<form action="" method="post">
    <?php
   
echo $captcha->render() ;
   
?>
<input type="submit" name="submit" value="Submit">

</form>


For more information send a message to info at phpclasses dot org.