0

I am using hCaptcha and it is working fine. The only problem is that on top of the website some hCaptcha response is shown after submitting the form.

When the hCaptcha has not been used the response output looks like this:

{"success":false,"error-codes":["missing-input-response"]}

When it has been successful I got a similiar success output.

I don't know where it is coming from. How can this output be disabled or hidden? There is no CSS class around it.

I have used the code integration from here: https://medium.com/@hCaptcha/using-hcaptcha-with-php-fc31884aa9ea, like this:

if ($_POST) {
$data = array(
    'secret' => "123",
    'response' => $_POST['h-captcha-response']
);
$verify = curl_init();
curl_setopt($verify, CURLOPT_URL, "https://hcaptcha.com/siteverify");
curl_setopt($verify, CURLOPT_POST, true);
curl_setopt($verify, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($verify, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($verify);
$responseData = json_decode($response);
if ($responseData->success) {
... }

And I have included this:

<script src='https://www.hCaptcha.com/1/api.js' async defer></script>

The code in dev-tools for a successful response look like this: Screenshot dev-tools HTML

Gunnarius
  • 59
  • 5
  • 1
    Looks like somewhere you may have an `echo` of the json response in your PHP. Are you for certain you are not echoing that out somewhere in your code? – IncredibleHat Mar 22 '22 at 13:59
  • 2
    What have you tried to resolve the problem? Where are you stuck? The given code does not print anything – Nico Haase Mar 22 '22 at 13:59
  • Thank you for your answers. I am sure there is no echo output. Yes, that is the strange thing. There is no echo($response) or some eco. I will check again. So I was thinking there is a configuration setting, but I did nit find it. I have read and checked the documentation, searched the internet and debugged the code. – Gunnarius Mar 22 '22 at 14:22
  • For kicks go ahead and add this line `curl_setopt($verify, CURLOPT_VERBOSE, false);` right before `curl_exec` ... and then double-check again that the setopt for `CURLOPT_RETURNTRANSFER` is actually there, spelled right, and true. It sounds like for some reason that is not getting set for your curl action. – IncredibleHat Mar 22 '22 at 19:07

0 Answers0