reCAPTCHA said: incorrect-captcha-sol

76 views
Skip to first unread message

gazza

unread,
Jan 5, 2010, 7:52:01 PM1/5/10
to reCAPTCHA
Hi everyone. I am continually experiencing problems with the reCAPTCHA
form.

Just for the record I am using PHP.

The reCAPTCHA is appearing on my form, I get the following error
message when the form is sent "reCAPTCHA said: incorrect-captcha-sol"

Form: http://www.freeworkout.co.uk/user/register_form.php

Can anyone see what I'm doing wrong? It's really important that I get
it working.

--------------------------
Server Side Code
--------------------------

<?php

require_once('recaptchalib.php');
$publickey = "MYPUBLICKEY";
$privatekey = "MYPRIVATEKEY";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("The reCAPTCHA wasn't entered correctly. Go back and try it
again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
// Your code here to handle a successful verification

//create short variable names
$email=$_POST['email'];
$username=$_POST['username'];
$passwd=$_POST['passwd'];
$passwd2=$_POST['passwd2'];
$gender=$_POST['gender'];
$bday=$_POST['bday'];
$bmonth=$_POST['bmonth'];
$byear=$_POST['byear'];
$question=$_POST['question'];
$answer=$_POST['answer'];

// start session which may be needed later
// start it now because it must go before headers

try {
// check forms filled in
if (!filled_out($_POST)) {
throw new Exception('You have not filled the form out correctly
- please go back and try again.');
}

// email address not valid
if (!valid_email($email)) {
throw new Exception('That is not a valid email address. Please
go back and try again.');
}

// passwords not the same
if ($passwd != $passwd2) {
throw new Exception('The passwords you entered do not match -
please go back and try again.');
}

// check password length is ok
// ok if username truncates, but passwords will get
// munged if they are too long.
if ((strlen($passwd) < 6) || (strlen($passwd) > 16)) {
throw new Exception('Your password must be between 6 and 16
characters Please go back and try again.');
}

if (($answer) > 0){
throw new Exception('You must enter and question and answer.');
}

// attempt to register
// this function can also throw an exception
register($username, $email, $passwd, $postcode, $country, $gender,
$bday, $bmonth, $byear, $question, $answer);
// register session variable
$_SESSION['valid_user'] = $username;

// provide link to members page
do_html_header('Registration successful');

echo 'Congratulations your registration was successful.';
do_html_url('index.php', 'Click here to activate your account');

// end page
do_html_footer();
}
catch (Exception $e) {
do_html_header('Problem:');
echo $e->getMessage();
do_html_footer();
exit;
}
}
?>

Charles Sweeney

unread,
Jan 8, 2010, 6:20:21 PM1/8/10
to reCAPTCHA
gazza wrote:
> Hi everyone. I am continually experiencing problems with the reCAPTCHA
> form.
>
> Just for the record I am using PHP.
>
> The reCAPTCHA is appearing on my form, I get the following error
> message when the form is sent "reCAPTCHA said: incorrect-captcha-sol"
>
> Form: http://www.freeworkout.co.uk/user/register_form.php
>
> Can anyone see what I'm doing wrong? It's really important that I get
> it working.

If it was me, I would start by fixing the 181 validation errors on the
form page:

http://validator.w3.org

--
Charles Sweeney
http://FormToEmail.com
PHP mail script with reCAPTCHA

Reply all
Reply to author
Forward
0 new messages