Page 1 of 1

Using CAPTCHA within Include files

Posted: Thu Jul 09, 2009 8:58 am
by simonmlewis
I am building a support page using this:
http://www.phpcaptcha.org/documentation/quickstart/

I can get the script to work completely if I post the form result to a *.php page. However, if I post it to an include file, it fails.

From reading about it, it needs to run the session at the very start of the page, which thru an include file, obviously won't be.

Is there a way to run it on an include page?

This is the code on the page being posted to:

Code: Select all

<?php session_start(); 
include_once "securimage/securimage.php";
 
$securimage = new Securimage();
 
if ($securimage->check($_POST['captcha_code']) == false) {
  // the code was incorrect
  // handle the error accordingly with your other error checking
 
  // or you can do something really basic like this
  die('The code you entered was incorrect.  Go back and try again.');
}
else
{
echo "yes!!";}
?>

Simon