Google验证码是否可以在本地工作但不能在服务器上运行?

时间:2017-07-17 07:25:17

标签: php codeigniter-3

我在本地进行了测试并且工作正常,然后我上传了它并创建了新的Google验证码,但它无效。

这是我的代码:

+视图

<form action="/register" method="post" enctype="multipart/form-data">
<input type="hidden" name="<?=$csrf['name'];?>" value="<?=$csrf['hash'];?>" />
    <div class="g-recaptcha set-captcha" data-sitekey="6LfiTykUAAAAAN6-98TDoIVHNMVedR6jtKAEXa6S"></div>
<button type="submit" class="button userlogin">Apply</button>

+控制器:

public function _submit_register(&$data){

$form_response = $this->input->post('g-recaptcha-response');
$url = "https://www.google.com/recaptcha/api/siteverify";
$sitekey = "6LfiTykUAAAAAOYfu_NGbeUHuq_dZxO5_n0oynMO";
$response = file_get_contents($url."?secret=".$sitekey."&response=".$form_response."&remoteip=".$_SERVER["REMOTE_ADDR"]);
$data_cap = json_decode($response);

if(isset($data_cap->success) && $data_cap->success=="true")
    {
        $insert_id = $this->mo_user->insert($dealer_data);
    }
    else
    {
        echo "<script>alert('Please fill captcha')</script>";
    }
}

请帮我解决这个问题!!!

谢谢你的帮助!!!

0 个答案:

没有答案
相关问题