本文介绍了未定义的索引:recaptcha_challenge_field; recaptcha_response_field的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一个reCAPTCHA实现到
PHP中的注册用户页面,但是我继续收到警告,我的用户没有得到

在数据库中注册。在尝试添加reCAPTCHA之前,

注册正常工作。



警告1:未定义索引:recaptcha_challenge_field(行给出

这个警告是$ _POST [recaptcha_challenge_field],)



警告2:未定义索引:recaptcha_response_field(行给出

这个警告是$ _POST [recaptcha_response_field]);)



------------------我的代码------------------- -

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帮助解决这个问题


PLZ HELP TO RESOLVE THIS PROBLEM

推荐答案


<?php <br mode="hold" /??>        // reCAPTCHA stuff 
        require_once('recaptchalib.php');



这篇关于未定义的索引:recaptcha_challenge_field; recaptcha_response_field的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 18:38