您好,我有一个我制作的表单,它可以在本地计算机上运行,但不会在实时服务器上运行get\\u file\\u内容,因为它在响应中返回NULL?
形式:
<form name="contactUS" action="<?php echo get_template_directory_uri(); ?>/mail/contact-us-mail-recaptcha.php" method="post">
<input name="name" type="text" placeholder="Name">
<input name="email" type="email" placeholder="Email">
<input name="message" type="textarea" placeholder="Please describe your project and the work to be done?">
<div class="g-recaptcha" data-sitekey="<site key>"></div>
<button type="submit" class="nsc-button">Submit</button>
</form>
服务器代码:
<?php
$recaptcha_secret = \'<secret key>\';
$ip = $_SERVER[\'REMOTE_ADDR\'];
$captchaResponse = $_POST[\'g-recaptcha-response\'];
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$recaptcha_secret."&response=".$captchaResponse);
$result = json_decode($response, true);
if($result == true){
//do success
}else {
var_dump(\'ip:\' . $ip);
var_dump(\'captchaResponse:\' . $captchaResponse);
var_dump(\'response:\' . $response);
var_dump(\'result:\' . $result);
exit;
}