This article is intended for developers using reCAPTCHA Library for PHP (recaptcha-php-1.11).
Problem
When I access my website over SSL, Google Recaptcha doesn’t load.
When I access the javascript error console, I see the following error:
Blocked loading mixed active content
“https://www.google.com/recaptcha/api/challenge?k=KEY-GOES-HERE” [Learn More]
What causes this problem?
You will see the Blocked loading mixed active content error when accessing your website over https (ssl) but calling Google’s recaptcha using http (no ssl). Your browser is blocking the insecure content which is trying to load over http (no ssl).
Solution
The solution to this problem is to use SSL when calling the recaptcha_get_html
function to create your recaptcha form.
If you look at around line 106 of recaptcha-php-1.11/recaptchalib.php, you’ll see the function has an optional ssl parameter:
function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)
Changing your code from the red example below to the green example below should fix this error for you:
$recaptcha = recaptcha_get_html($publickey); $recaptcha = recaptcha_get_html($publickey,'',true);
Although I could find:
function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)
in recaptchalib.php
I could not find:
However changing
to
worked.
Thank you
Thank you so much! This was exactly the solution I was looking for.