How do I add a link on a page and only proceed after I do recaptcha?

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

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

Then, after it does the recaptcha check, that, the error happens. I added site key and secret key as per the code below. What I don't know is to add the referral link.

Error occurred:

Method not allowed Error 405

I tried this a code that a young man created, I saw another doubt similar to mine more was not about link can someone help me please? I really needed to work this out.

Where I tested: 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>
Author: Matheus, 2019-08-19

1 answers

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

 0
Author: Mbosso, 2019-08-19 17:04:24