How to add a link to a page and only proceed after you do recaptcha?

Asked

Viewed 66 times

0

I want to do the same as this site, add a link and only go through it if you check in recaptcha.

https://www.androidtunado.com.br/p/pagina-de-download_987.html?

Then, after you do the recaptcha check, that, error happens. I added site key and secret key as the code below. What I don’t know is to add the link reference.

Error occurred:

method not allowed Error 405

I tried it a code that a young man created, I saw another question similar to mine but it wasn’t about link anyone can help me, please? I really needed to fix this.

Where I tested it: https://www.euhtmods.com/p/pagina-de-download_19.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Conteudo a ser Bloqueado</title>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<h1>
Exemplo</h1>
<?php
   $resposta = false;
   if (isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])) {
      $captcha_data = $_POST['g-recaptcha-response'];
      $chave_secreta = "CHAVE-SECRETA";   
      $resposta = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$chave_secreta&response=$captcha_data&remoteip=".$_SERVER['REMOTE_ADDR']);
   }
   if ($resposta) {
   ?>
<p>
Por favor, verifique a caixa de captcha para prosseguir para a página de destino!</p>
<?php
   }
   ?>

<?php
   if(!$resposta){
   ?>
<form method="post" onsubmit="return validar()">
<div class="g-recaptcha" data-callback="recaptchaCallback" data-sitekey="CHAVE-DE-SITE">
</div>


<button type="submit" class="button">Prosseguir para o Download</button>
</form>
<script>
   googlerecpchk = false;
   function recaptchaCallback() {
      googlerecpchk = true;
   };

   function validar(){

      console.log(googlerecpchk);
      if(!googlerecpchk){
         alert("Por favor, verifique a caixa de captcha para prosseguir para a página de destino!");
         return false;
      }

   }
   </script>
<?php
   }
   ?>

</body>
</html>

  • watch this video https://www.youtube.com/watch?v=AuWsUDaOQdM

  • configured this error when adding a link that I don’t know how to solve unfortunately

1 answer

0

Try to leave the tag form like this: <form method="post" onsubmit="validar();">, you don’t need to use return validar() just put the function name.

  • tried... did not give the error maybe it is some code that is making it occur.

  • $reply = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$chave_secreta&Response=$captcha_data&remoteip=".$_SERVER['REMOTE_ADDR']); I think this is what gives error but I do not know what to fix the error. file_get_contents tells that this error occurs. https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405

  • You are testing on a local server(localhost)?

  • trying on the same blogger

Browser other questions tagged

You are not signed in. Login or sign up in order to post.