I am trying to create a chaptcha that a user only has to submit once
so they can browse a website without having to complete a captcha any
time they want to fill out a form. I plan to accomplish this by the
use of a setcookie() that will expire in a year. However, when I try
to verify that I am a human, it gives me this error message:
Warning: Cannot modify header information - headers already sent by
(output started at /home/rusawn5/public_html/arrowheaddev/inc/
template.php:12) in /home/rusawn5/public_html/arrowheaddev/
verifyHuman.php on line 23
Now, I have commented out the setcookie() and it works fine so I know
my problem lies with the cookie. I would appreciate any help with a
work-around.
Here is the website:
http://dev.arrowheadcfo.com/
Here is the Captcha:
http://dev.arrowheadcfo.com/verify.php
Here is the Code of verifyHuman.php:
<?php
require_once('inc/recaptchalib.php');
$privatekey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
die ("The reCAPTCHA wasn't entered correctly. Go back and try it
again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
$camperExpire = time()+60*60*24*30*12;
setcookie("cfoCamper", "human", $camperExpire);
echo "<br><br><center><h3>Thank you very much for verifying that
you are a CFO camper! You may now browse the site without having to be
bothered with the captcha again.</h3></center><br><br>";
}?>