Google Captcha not showing up in secure GoDaddy (https)

I had a problem when Google reCaptcha doesn’t appear on my https website and wondered if anyone else had this problem and found it.

In my test environment (localhost), it looks great, and I can send and receive forms. However, when you upload it to my secure GoDaddy website, the image / div reCaptcha DOES NOT, and I don’t know why.

Please, help.

The following are parts of my code (which worked in localhost):

inside the head tags

<script src='https://www.google.com/recaptcha/api.js'></script> 

inside the "body", where the recaptcha actually appears:

 <div class="contact_text"> <div class="g-recaptcha" id="googlecaptcha" data-sitekey="SITEKEYPLACEHOLDER"></div> <?php echo "<p class='text-danger col-xs-offset-6 col-xs-6'>$errCaptcha</p>";?> </div> 

then the "php" part:

 $captcha = $_POST['g-recaptcha-response']; $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=SECRETKEYPLACEHOLDER&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']); if($response.success==false){ $errCaptcha = 'Please check captcha form'; } 

I based on this lesson https://codeforgeek.com/2014/12/google-recaptcha-tutorial/

To repeat, the code / page / form works in my localhost test environment, but DOES NOT SHOW when uploading to my https website hosted on GoDaddy.

I appreciate any help or suggestions. Thanks.

Update:

Since I and no one have any links to this topic, I decided to go to another captcha called "secureimage", which adequately fulfilled my needs. I will keep this question open as I really want to use Google captcha due to the intuitively impressive checkbox style captcha style.

Hope someone finds a way in the near future.

Decision:

Removing "https:" from the source path displays Google reCaptcha correctly!

 <script src='//www.google.com/recaptcha/api.js'></script> 

Now the block and form of the code are working. Thanks Matthew3k!

+6
source share
1 answer

Remove "https:" from the source path.

 <script src='//www.google.com/recaptcha/api.js'></script> 

I found this method successful for loading cross-domain resources on secure sites.

+4
source

Source: https://habr.com/ru/post/989375/


All Articles