PHP Classes

File: examples/recaptcha-captcha.php

Recommend this page to a friend!
  Classes of sameer shelavale   PHP Multi CAPTCHA   examples/recaptcha-captcha.php   Download  
File: examples/recaptcha-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: 9 years ago
Size: 741 bytes
 

Contents

Class file image Download
<?php

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


$captcha = new \MultiCaptcha\Captcha([
   
'secret'=> "form1-secret-key",
   
'options' => [
       
'recaptcha' => [
           
'publicKey'=> "6Le1XPQSAAAAAPteoelqqH7JQzKGOikcTc3HrpAA", // replace this with your public key
           
'privateKey' => "6Le1XPQSAAAAABu9LOXfj6Wxvec_cQFXCHjOJzG3" // replace this with your private key
       
]
    ]
] );


if( 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>