Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1130349
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 6 years ago.
Improve this questionHi I have a form I've made that works on my local machine but doesn't run the get_file_contents on the live server as it returns NULL on the response?
Form:
<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>
Server Code:
<?php
$recaptcha_secret = '<secret key>';
$ip = $_SERVER['REMOTE_ADDR'];
$captchaResponse = $_POST['g-recaptcha-response'];
$response = file_get_contents("=".$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;
}
Closed. This question is off-topic. It is not currently accepting answers.
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 6 years ago.
Improve this questionHi I have a form I've made that works on my local machine but doesn't run the get_file_contents on the live server as it returns NULL on the response?
Form:
<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>
Server Code:
<?php
$recaptcha_secret = '<secret key>';
$ip = $_SERVER['REMOTE_ADDR'];
$captchaResponse = $_POST['g-recaptcha-response'];
$response = file_get_contents("https://www.google/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;
}
Share
Improve this question
asked Jan 3, 2019 at 7:25
danbdexdanbdex
113 bronze badges
2
- Make sure you added your domain URL in google developer recaptcha configuration. – Pratik Patel Commented Jan 3, 2019 at 7:35
- thank you yes the url is added I confirmed this other wise there is an error recaptcha box on the form – danbdex Commented Jan 3, 2019 at 7:36
1 Answer
Reset to default 0Tip A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.
So most probably allow_url_fopen is set to false on your server.
But you shouldn’t use that function - use wp_remote_get instead.
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 6 years ago.
Improve this questionHi I have a form I've made that works on my local machine but doesn't run the get_file_contents on the live server as it returns NULL on the response?
Form:
<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>
Server Code:
<?php
$recaptcha_secret = '<secret key>';
$ip = $_SERVER['REMOTE_ADDR'];
$captchaResponse = $_POST['g-recaptcha-response'];
$response = file_get_contents("=".$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;
}
Closed. This question is off-topic. It is not currently accepting answers.
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 6 years ago.
Improve this questionHi I have a form I've made that works on my local machine but doesn't run the get_file_contents on the live server as it returns NULL on the response?
Form:
<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>
Server Code:
<?php
$recaptcha_secret = '<secret key>';
$ip = $_SERVER['REMOTE_ADDR'];
$captchaResponse = $_POST['g-recaptcha-response'];
$response = file_get_contents("https://www.google/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;
}
Share
Improve this question
asked Jan 3, 2019 at 7:25
danbdexdanbdex
113 bronze badges
2
- Make sure you added your domain URL in google developer recaptcha configuration. – Pratik Patel Commented Jan 3, 2019 at 7:35
- thank you yes the url is added I confirmed this other wise there is an error recaptcha box on the form – danbdex Commented Jan 3, 2019 at 7:36
1 Answer
Reset to default 0Tip A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.
So most probably allow_url_fopen is set to false on your server.
But you shouldn’t use that function - use wp_remote_get instead.
本文标签: formsrecaptcha working on local but not on live wordpress sites
版权声明:本文标题:forms - recaptcha working on local but not on live wordpress sites 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749049513a2308395.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论