Search code examples
phprecaptcha

reCaptcha always returns false on iPage host


I have a recaptcha that will not work for a specific site and I can't figure why. On my host it works fine, but when I test on an iPage host, it always returns false, even with a simple test form, it is always false.

I have tried re-doing keys. I even made the very basic of forms as you can see below, but always returns false. And no errors.

http://legionoffoam.com/new/form.html

form.html

<html>
<head>
    <script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
    <form action="test-recaptcha.php" method="post">
        <div class="g-recaptcha" data-sitekey="6LdXvCYTAAAAAOzMaqHb6lFZrIVnATbo7PxzvSfS"></div>
        <input type="submit" value="SUBMIT" id="submit">
    </form>
</body>
</html>

test-recaptcha.php

<?php

require_once "recaptchalib.php";

$secret = "<<SECRET>>";

$response = null;
$reCaptcha = new ReCaptcha($secret);

if ($_POST['g-recaptcha-response']) {
    $response = $reCaptcha->verifyResponse(
        $_SERVER["REMOTE_ADDR"],
        $_POST['g-recaptcha-response']
    );
}

var_dump($response);
var_dump($_POST);

reponse:

{["success"]=> bool(false) ["errorCodes"]=> NULL }

Solution

  • The problem is with the default php.ini file that iPage uses.

    'allow_url_fopen' is set to off by default, change this to on and everything should work fine.

    To change this setting go to: cPanel > CGI and Scripted Language Support > PHP Scripting