Click here to Skip to main content
16,018,419 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
<?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
Posted
Updated 26-Sep-12 19:37pm
v3
Comments
Sergey Alexandrovich Kryukov 27-Sep-12 2:21am    
Where is your HTML? It is needed to pinpoint the problem exactly. However, you can do it by yourself...
--SA

Most likely, it simply means that in your form (using the method="post" attribute) there are no controls with the name attributes with the values "recaptcha_challenge_field" and "recaptcha_response_field". They should be there, please check up. The form sends HTTP request using this attribute with becomes the index of PHP $_POST.

—SA
 
Share this answer
 
v2
Cheers...... same problem for me tooooooooooooooooo...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900