Recaptcha Invisible

0

I'm trying to implement Captcha ReCaptcha Invisible on my site but I do not know how to do this implementation, how can I do that? (Yes, I already have the host registered). If it is interesting (I think so) the site is this: link

I'll put down the code in PHP and HTML form. I did not find the syntax error, but it might be that someone found it.

HTML:

<form class="form" id="form1" method="POST" action="mail.php">
    <p class="name">
        <input name="name" type="text" class="validate[required,custom[onlyLetter],length[0,100]] feedback-input" placeholder="Nome" id="name" />
    </p>
    <p class="email">
        <input name="email" type="text" class="validate[required,custom[email]] feedback-input" id="email" placeholder="Email" />
    </p>
    <p class="phone">
        <input name="tel" type="text" class="validate[required,custom[email]] feedback-input" id="phone" placeholder="Telefone (Com DDD)" />
    </p>
    <p class="text">
        <textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="Produtos"></textarea>
    </p>

    <div class="submit">
        <button class="g-recaptcha" data-sitekey="6LdIgR4UAAAAALrbj6sHWoRU6v9zZgDXp71MXQiX" data-callback='onSubmit' name="enviar" type="submit" value="submit" id="button-blue" formmethod="POST"> ENVIAR </button>
            <div class="ease"></div>
            <div class="g-recaptcha"
                data-sitekey="6LdIgR4UAAAAALrbj6sHWoRU6v9zZgDXp71MXQiX"
                data-callback="onSubmit"
                data-size="invisible">
            </div>
    </div>
</form>

PHP:

<?php

date_default_timezone_set('America/Sao_Paulo');
ini_set('display_errors', 'On');

if (isset($_POST['g-recaptcha-response'])) {
    $captcha_data = $_POST['g-recaptcha-response'];
}
// Se nenhum valor foi recebido, o usuário não realizou o captcha
if (!$captcha_data) {
    echo "Por favor, confirme o captcha.";
    exit;
}
$resposta = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=6LdIgR4UAAAAABjwVcXRmnAKp1BzfnTdbFm4inx0&response=".$captcha_data."&remoteip=".$_SERVER['REMOTE_ADDR']);

if ($resposta.success) {


if($_POST['name'] && $_POST['text'] && $_POST['tel'] != ''){
    require "classes/PHPMailer-master/PHPMailerAutoload.php";

    $GetPost = filter_input_array(INPUT_POST,FILTER_DEFAULT);
    $mensagem = "<html><head><center><img src=\"http://madeireirapadroeira.com.br/image/logo.png\"></center></head><body style=\"background-color:#FFF;font-family:Segoe UI;font-site:14px;color:#000;\">
        <br /><br />
        <b>Email de Contato - Orçamento Feito Pelo Site</b>
        <br /><br />
        <hr style=\"width:100%;border:1px solid #3399CC\" /><br />
        <b>Nome:</b> ".$_POST['name']."<br /><br />
        <b>E-mail:</b> ".$_POST['email']."<br /><br />
        <b>Telefone:</b> ".$_POST['tel']."<br /><br />
        <b>Mensagem:</b> ".nl2br($_POST['text'])."<br /><br />
        <hr style=\"width:100%;border:1px solid #3399CC\" />
        </body></html>";
    $mail = new PHPMailer;

    //$mail->SMTPDebug = 3;                               // Enable verbose debug output

    $mail->isSMTP();                                      // Set mailer to use SMTP
    $mail->Host = 'mail.madeireirapadroeira.com.br';  // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = '[email protected]';                 // SMTP username
    $mail->Password = 'SENHA';                           // SMTP password
    //$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, 'ssl' also accepted
    $mail->Port = 587;                                    // TCP port to connect to

    $mail->setFrom('[email protected]','Contato de Orcamento Feito Pelo Site');
    $mail->addAddress('[email protected]');     // Add a recipient
    //$mail->addAddress('[email protected]');     // Add a recipient

    $mail->isHTML(true);                                  // Set email format to HTML

    $mail->Subject = "Contato feito pelo site do {$_POST['name']} feito as ".date("H:i")." - ".date('d/m/Y');
    $mail->Body    = "$mensagem";
    $mail->AltBody = "$mensagem";

    if(!$mail->send()) {
        echo 'Erro. Orçamento não enviado. Por favor tente novamente';
        echo 'ERRO: ' . $mail->ErrorInfo;
    } else {
        echo '<br />O seu orcamento foi enviado para uma de nossas atendentes. por favor, aguarde o retorno brevemente.<br /><br /> <a href="http://madeireirapadroeira.com.br"><button><b>CLIQUE AQUI PARA VOLTAR AO SITE!</b></button></a>';
    }
}
    } else {
    echo "Usuário mal intencionado detectado. A mensagem não foi enviada.";
    exit;
}
?>
    
asked by anonymous 16.05.2017 / 21:02

1 answer

0

From what I saw on the site, the problem is only in the id of your form.

Try to put it like this and insert it into your page in this method:

function onSubmit(token) {
            document.getElementById("orcamento").submit();
            grecaptcha.execute();
        }

Switch to:

    function onSubmit(token) {
    			document.getElementById("form1").submit();
    			grecaptcha.execute();
    		}
    
17.05.2017 / 15:41