Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法实现TCHA_Javascript_Php_Recaptcha_Invisible Recaptcha - Fatal编程技术网

Javascript 无法实现TCHA

Javascript 无法实现TCHA,javascript,php,recaptcha,invisible-recaptcha,Javascript,Php,Recaptcha,Invisible Recaptcha,我的密码恢复表单位于js函数中: function openBeaconPasswordRecovery() { $.unblockUI(); blockMsg( '<div> Title<br> <form> <input placeholder="example@gmail.com"

我的密码恢复表单位于js函数中:

    function openBeaconPasswordRecovery() {
        $.unblockUI();
        blockMsg(
            '<div>
                Title<br>
                <form>
                    <input placeholder="example@gmail.com" id="recoverEmail" name="recoverEmail" class="txtInput" type="text" onblur="validateMail(this.value)"/>
                    <span id="errorRecoverEmail"></span>
                    <div id="tdRecoverEmail" style="display: none"></div>
                    <div id="recaptcha" class="g-recaptcha" data-sitekey="6LdekygUAAAAANGSgYNCNhDRQpgwT-_ZNKWzlpa4" data-callback="sendPasswordRecovery()" data-size="invisible"></div>
                    <input type="button" value="Send" id="passwordRecoveryButton" id="submit" class="btn_big_entrar">
                    </div>
                </form>
                <script>onload();</script>
            ', 150);
    }

但是当我点击submit按钮时什么也没有发生,请告诉我哪里错了?

你在哪里绑定你的按钮来发送Ajax调用?我们的表单标签看起来像什么?@AlexanderHiggins:在reCaptcha div内的数据回调中。表单看起来像这样:
function validateMail(email){
        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

        if (reg.test(email) == false){
            document.getElementById("tdRecoverEmail").innerHTML = "<img src='../common/images/error.gif'>";
            document.getElementById("errorRecoverEmail").innerHTML = "<br>Invalid email";
            document.getElementById("passwordRecoveryButton").disabled = true;
            return;
        }
        else{
            document.getElementById("tdRecoverEmail").innerHTML = "<img src='../common/images/ok.gif' style='padding-top: 2px'>";
            document.getElementById("errorRecoverEmail").innerHTML = "";
            document.getElementById("passwordRecoveryButton").disabled = false;
        }
    }
function sendPasswordRecovery(){
        var AJ = new Ajax();
        try{
            AJ.setUrl("../main/forgotPass.php");
            AJ.setVar("sEmail"      , $("#recoverEmail").val());
            AJ.setMethod("POST");
            AJ.setOnLoading(sendPasswordRecoveryLoading);
            AJ.setOnComplete(sendPasswordRecoveryComplete);
            AJ.connect();
            AJ.getData();
        }
        catch(e){
        }
    }

    function sendPasswordRecoveryLoading(){
        blockMsg('Processing...');
    }

    function sendPasswordRecoveryComplete(httpRequest, AJ){
        var resp = httpRequest.responseText;

        reload = 1;
        if ((resp == "2") || (resp == 2)){
            blockMsg('<div><p>Response A</p></div>', 1);
        }
        else{
            blockMsg('<div><p>Response B</p></div>', 1);
        }
    }
function sendMail(){

// reCaptcha info
$secret         = "private_key";
$remoteip       = $_SERVER["REMOTE_ADDR"];
$url            = "https://www.google.com/recaptcha/api/siteverify";

// Form info
$response       = $_POST["g-recaptcha-response"];
$sEmail         = $_POST["sEmail"];

// Curl Request
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, array(
    'secret' => $secret,
    'response' => $response,
    'remoteip' => $remoteip
));
$curlData = curl_exec($curl);
curl_close($curl);

// Parse data
$recaptcha = json_decode($curlData, true);

if ($recaptcha["success"]){
    $objUser = Users::FindFirst("Users", "email = '" . $sEmail . "'");

    if (!$objUser)
        echo 0;

    else{
        if($objUser->deleted == 1 || $objUser->deleted == "1")
            echo 2;

        else{
            $vUsersMail[$objUser->name . " " . $objUser->surname] = $objUser->email;

            $h = md5($objUser->id);
            $g = md5($objUser->password);

            $params = "h=" . $h . "&g=" . $g . "&uid=" . $objUser->id;

            if (sendMails("ForgotPass",$vUsersMail,"", null, $params))
                echo 1;
            else
            echo 0;
        }
    }
}
else
    echo 0;

exit;}