为什么Google Recaptcha没有在我的流程中回叫?

时间:2019-03-09 02:08:42

标签: php recaptcha

  

已编辑:我已在管理面板中注册了域

     

blabla.org

     

但它仍然不起作用

所以我要对Google Recaptcha验证进行一些处理。

但是当我单击按钮过程时。

无法检测到$ response,并且给出了空内容。

这是我的代码

$site_key = 'secret';
$secret_key = secret'; 
if(isset($_POST['req_token'])){ 
    if(isset($_POST['g-recaptcha-response']))
       {
       $api_url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . $secret_key . '&response='.$_POST['g-recaptcha-response'];
       $response = file_get_contents($api_url);
       $data = json_decode($response);
        if($data['success'])
           {
            $nama                       =$_POST['nama'];
            $email                      =$_POST['email'];
            $telp_1                     =$_POST['telp_1'];
            $status_id                  = 1;
           $sql="INSERT INTO data_recruitment
                                       (   status_id,
                                           nama,
                                           email,
                                           telp_1
                                       )
                                       VALUES
                                       (   '$status_id',
                                           '$nama',
                                           '$email',
                                           '$telp_1'
                                       )";
                                       if(mysqli_query($conn, $sql)){ // jika query insert berhasil dieksekusi
                                       header("location:../index.php?status=1");
                                       }
                                       else{
                                       header("location:../index.php?status=2");
                                       }    
        } else
        {
               header("location:../index.php?status=4");
           }
    }
   else{
           header("location:../index.php?status=3");
   }  
}
我的服务器未检测到

$ response。但是当我在本地主机测试时。该过程运行正常。

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

您看过这个吗? file_get_contents returns empty string

您可能想要执行phpinfo()并查看服务器正在运行的版本。