is_valid) {
$_SESSION['contactform']['passedimage'] = true;
return true;
}
return false;
}
if(!isset($_SESSION['contactform']['passedimage'])){//We dont want to show the user the image verification if they have already passed it.
$_SESSION['contactform']['passedimage'] = false;
}
require_once($_SERVER['DOCUMENT_ROOT']."/tutorials/formprocessor/contact/recaptchalib.php");//Include the recaptcha class
$javascript = <<
var RecaptchaOptions = {
theme: 'custom',
lang: 'en',
custom_theme_widget: 'recaptcha_widget'
};
EOD;
//These keys will work on your server, you can apply for your own if you wish
$public = "6LcVYgQAAAAAABG5IOef21_v3tuhZXGRKEg-WXdP"; //Public Key for recaptcha
$private = "6LcVYgQAAAAAAJFjVVeejrCHaugQ0pT5dT10IvsV";//Private key for recaptcha
$error = null; //No Errors as of yet
$recaptchahtml = recaptcha_get_html($public, $error);//Get the recaptcha HTML - remember to global this in the form function
echo $javascript;//Display the recaptcha Javascript
function showForm(){
global $recaptchahtml;
$form = <<
Here is a basic example of the formprocessor, this is a simple input.
In this example:
You Must Provide your name.
Your Name must only contain letters
You Must Provide your email address.
Your Email must be in the a@b.com format
You must provide a subject
Your subject must be at least 5 characters long
You must fill in the message text area
Your message must be greater than 10 characters long
You must get the image verification correct
Error:
!
!
!
!
Incorrect please try again
Enter the words above:Enter the numbers you hear:!
{$recaptchahtml}
EOD;
return $form;
}
$processor =& new FormProcessor(showForm());
try{
if(isset($_POST["submit"])) {
if ($processor->validate()) {
echo 'The Form Was Submitted, Wahey! Here is the $_POST data';
echo '