Php 这辆车怎么了

Php 这辆车怎么了,php,recaptcha,captcha,Php,Recaptcha,Captcha,我已经试着让这个卡帕查工作了一段时间,但我不能让它工作,无论我试图做什么 当我改变的时候!==只是正如有人建议的那样,当我按下表单的“提交”按钮时,表单提交将以“真实”响应结束,即使按下“重新添加”框或忽略按下它。var_dump($responseKeys)的输出也总是给我一个“NULL”值,所以我无法找出哪里出了问题 有人知道为什么它不起作用吗 **PHP** // check captcha if(isset($_POST)){ $captcha=$

我已经试着让这个卡帕查工作了一段时间,但我不能让它工作,无论我试图做什么

当我改变的时候!==只是正如有人建议的那样,当我按下表单的“提交”按钮时,表单提交将以“真实”响应结束,即使按下“重新添加”框或忽略按下它。var_dump($responseKeys)的输出也总是给我一个“NULL”值,所以我无法找出哪里出了问题

有人知道为什么它不起作用吗

**PHP**

    // check captcha

 if(isset($_POST)){     
        $captcha=$_POST['g-recaptcha-response'];
        $ip = $_SERVER['REMOTE_ADDR'];
        $secretkey = "SECRET KEY";                    
        $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretkey."&response=".$captcha."&remoteip=".$ip);
        $responseKeys = json_decode($response,true);         


    if(intval($responseKeys["success"]) != 1) {

        //echo 'TRUE';
        //echo "<br>";
        //echo var_dump($responseKeys)."<br>";
        //exit;

    } else {

        //echo 'FALSE';
        //echo "<br>";
        //echo var_dump($responseKeys)."<br>";
        // exit;        
    }                   
}
**PHP**
//检查验证码
if(isset($_POST)){
$captcha=$_POST['g-recaptcha-response'];
$ip=$\u服务器['REMOTE\u ADDR'];
$secretkey=“秘密密钥”;
$response=文件\u获取\u内容(“https://www.google.com/recaptcha/api/siteverify?secret=“$secretkey.”&response=“.$captcha.”&remoteip=“.$ip”);
$responseKeys=json_decode($response,true);
if(intval($responseKeys[“success”])!=1){
//回声“真”;
//回声“
”; //echo var_dump($responseKeys)。“
”; //退出; }否则{ //回声“假”; //回声“
”; //echo var_dump($responseKeys)。“
”; //退出; } }
HTML

**<div class="span9 page_sidebar registerForm">
<?php
if (isErrors())
{
    echo outputErrors();
}
?>
<div class="well">
    <p>
        <?php echo t('register_intro_text', 'Please enter your information below to register for an account. Your new account password will be sent to your email address.'); ?>
    </p>
    <form id="regerform" method="post" action="https://<?php echo _CONFIG_SITE_FULL_URL; ?>/register.<?php echo SITE_CONFIG_PAGE_EXTENSION; ?>" class="form">
        <div class="third">
            <label for="title">
                <?php echo t("title", "title"); ?>:
            </label>
            <select autofocus="autofocus" tabindex="1" id="title" name="title">
                <option value="Mr"><?php echo t('title_mr', 'Mr'); ?></option>
                <option value="Mrs"><?php echo t('title_mrs', 'Mrs'); ?></option>
                <option value="Miss"><?php echo t('title_miss', 'Miss'); ?></option>
                <option value="Dr"><?php echo t('title_dr', 'Dr'); ?></option>
                <option value="Pro"><?php echo t('title_pro', 'Pro'); ?></option>
            </select>
        </div>
        <div class="third">
            <label for="firstname">
                <?php echo t("firstname", "firstname"); ?>:
            </label>
            <input type="text" tabindex="1" value="<?php echo isset($firstname) ? safeOutputToScreen($firstname) : ''; ?>" id="firstname" name="firstname">
        </div>
        <div class="thirdLast">
            <label for="lastname">
                <?php echo t("lastname", "lastname"); ?>:
            </label>
            <input type="text" tabindex="1" value="<?php echo isset($lastname) ? safeOutputToScreen($lastname) : ''; ?>" id="lastname" name="lastname">
        </div>
        <div class="clear"></div>
        <div>
            <label for="emailAddress">
                <?php echo t("email_address", "email address"); ?>:
            </label>
            <input type="text" tabindex="1" value="<?php echo isset($emailAddress) ? safeOutputToScreen($emailAddress) : ''; ?>" id="emailAddress" name="emailAddress">
        </div>
        <div>
            <label for="emailAddressConfirm">
                <?php echo t("email_address_confirm", "Email Confirm"); ?>:
            </label>
            <input type="text" tabindex="2" value="<?php echo isset($emailAddressConfirm) ? safeOutputToScreen($emailAddressConfirm) : ''; ?>" id="emailAddressConfirm" name="emailAddressConfirm">
        </div>
        <div class="thirdLast">
            <label for="username">
                <?php echo t("username", "username"); ?>:
            </label>
            <input type="text" tabindex="3" value="<?php echo isset($username) ? safeOutputToScreen($username) : ''; ?>" id="username" name="username">
        </div>
        <div class="clear"></div>

        <?php if(SITE_CONFIG_REGISTER_FORM_SHOW_CAPTCHA == 'yes'): ?>



        <div class="g-recaptcha" data-sitekey="PRIVATE KEY"></div>



        <?php endif; ?>

                    <div class="buttonWrapper">
            <button type="submit" name="submit" class="btn btn-primary" tabindex="99"><?php echo t("register", "register"); ?></button>
        </div>

        <input type="hidden" value="1" name="submitme"/>
    </form>

    <div class="disclaimer">
        <?php echo t('by_clicking_register_you_agree_to_our_terms', 'By clicking \'register\', you agree to our <a href="terms.[[[SITE_CONFIG_PAGE_EXTENSION]]]" target="_blank">terms</a>.', array('SITE_CONFIG_PAGE_EXTENSION'=>SITE_CONFIG_PAGE_EXTENSION)); ?>
    </div>
    <div class="clear"></div>
</div>
**


验证用户的方法有点不同。
g-recaptcha-response
通过POST请求发送到服务器端脚本, 还有注册时得到的reCAPTCHA密钥, 你把它传递给谷歌,告诉它用户是否是机器人。 响应是一个JSON响应,因此我们将使用
file\u get\u contents()
JSON\u decode()
获取响应,并决定如何使用脚本。 本例将为您提供编写自己的代码的想法

$response = $_POST["g-recaptcha-response"];
$url = 'https://www.google.com/recaptcha/api/siteverify'; 
//verify your site
$data = array(
    'secret' => 'YOUR_SECRET', 
    'response' => $_POST["g-recaptcha-response"]
);
$options = array(
    'http' => array (
        'method' => 'POST',
        'content' => http_build_query($data)
    )
);
$context  = stream_context_create($options);
$verify = file_get_contents($url, false, $context);
$captcha_success=json_decode($verify);
if ($captcha_success->success==false) {
    echo "<p>You are a bot! Go away!</p>";
} else if ($captcha_success->success==true) {
    echo "<p>You are not not a bot!</p>";
}
$response=$\u POST[“g-recaptcha-response”];
$url='1https://www.google.com/recaptcha/api/siteverify'; 
//验证您的站点
$data=数组(
“秘密”=>“你的秘密”,
“响应”=>$\u POST[“g-recaptcha-response”]
);
$options=array(
“http'=>数组(
'方法'=>'发布',
'content'=>http\u build\u查询($data)
)
);
$context=stream\u context\u create($options);
$verify=file\u get\u contents($url,false,$context);
$captcha\u success=json\u decode($verify);
如果($captcha\u success->success==false){
echo“你是个机器人!走开!

”; }else if($captcha\u success->success==true){ echo“你不是机器人!

”; }