Hi, I'm trying to implement a reCAPTCHA to a register user page in
PHP, but I continue to get a warning, and my users don't get
registered in the database. Before trying to add reCAPTCHA the
registration worked as it should.
Warning 1: Undefined index: recaptcha_challenge_field (line that gives
this warning is $_POST["recaptcha_challenge_field"],)
Warning 2: Undefined index: recaptcha_response_field (line that gives
this warning is $_POST["recaptcha_response_field"]);)
------------------ My Code ---------------------
<?php <br mode="hold" /??> // reCAPTCHA stuff
require_once('recaptchalib.php');
$publickey = "...";
$privatekey = "...";
// Tripplechecked that the keys are correct!
$resp = null;
$error = null;
// end reCAPTCHA stuff
if($_POST)
{
$username = $_POST['username'];
$password = $_POST['password'];
$confirm = $_POST['confirm'];
$email = $_POST['email'];
// Some checks to see if data was entered in the form
if($username == "")
{
// Logic for checking data
}
else
{
// Connect to database and check for already existing user names /
e-mails
// If none found, proceed with the below code
// reCAPTCHA stuff
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if(!$resp->is_valid)
{
echo $resp->error;
}// end reCAPTCHA stuff
else
{
// Register new user in database
}
}
}
?>
PLZ HELP TO RESOLVE THIS PROBLEM