【问题标题】:why google recaptcha did not call back in my process?为什么 google recaptcha 没有在我的过程中回调?
【发布时间】:2019-07-31 01:59:00
【问题描述】:

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

blabla.org

还是不行

所以我有一些谷歌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。但是当我在本地主机中测试时。该过程运行良好。

有什么建议吗?

【问题讨论】:

    标签: php recaptcha


    【解决方案1】:

    你看过这个吗? file_get_contents returns empty string

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

    【讨论】:

    • 我在我的服务器上使用 php 7。它应该可以找到:(
    • 我检查了我的 php.ini 。一切准备就绪。 allow_url_fopen = 开启
    猜你喜欢
    • 1970-01-01
    • 2012-01-30
    • 2017-10-08
    • 1970-01-01
    • 2023-03-19
    • 2021-05-22
    • 2015-10-05
    • 2012-05-19
    • 2022-07-03
    相关资源
    最近更新 更多