-1
Hello. Well, I got this code right here. But I have a problem... reCaptcha appeared on my website, but the person can send the form even if they have not done the Captcha step...
<form action="" method="post" name="power" id="power">
<p class="contato-aviso">Os campos com <b>"*"</b> são obrigatórios!!</p>
<div class="form-group row">
<div class="col-sm-3">
<label for="nome">Nome<b style="color: red; font-size: 13px;">*</b></label>
</div>
<div class="col-9">
<input class="form-control" name="nome" type="text" id="nome" placeholder="Nome Completo" required>
</div>
</div>
<div class="form-group row">
<div class="col-sm-3">
<label for="facebook">Facebook</label>
</div>
<div class="col-9">
<input class="form-control" name="facebook" type="text" id="facebook" placeholder="Link do Perfil no Facebook">
</div>
</div>
<div class="form-group row">
<div class="col-sm-3">
<label for="skype">Skype</label>
</div>
<div class="col-9">
<input class="form-control" name="skype" type="text" id="skype" placeholder="Contato Skype">
</div>
</div>
<div class="form-group row">
<div class="col-sm-3">
<label for="discord">Discord</label>
</div>
<div class="col-9">
<input class="form-control" name="discord" type="text" id="discord" placeholder="Contato Discord">
</div>
</div>
<div class="form-group row">
<div class="col-sm-3">
<label for="assunto">Assunto<b style="color: red; font-size: 13px;">*</b></label>
</div>
<div class="col-9">
<input class="form-control" name="assunto" type="text" id="assunto" placeholder="Assunto" required>
</div>
</div>
<div class="form-group row">
<div class="col-3">
<label for="email">Email<b style="color: red; font-size: 13px;">*</b></label>
</div>
<div class="col-9">
<input class="form-control" name="email" type="email" id="email" placeholder="E-mail" maxlength="40" required>
</div>
</div>
<div class="form-group row">
<div class="col-3">
<label for="mensagem">Mensagem<b style="color: red; font-size: 13px;">*</b></label>
</div>
<div class="col-9">
<textarea class="form-control" name="mensagem" id="mensagem" placeholder="Sua Mensagem" rows="5" required></textarea>
</div>
</div>
<center>
<div name="grecaptcha" id="grecaptcha" class="g-recaptcha" data-sitekey="6LfFGFUUAAAAAI3s5OAuRlm1IVUaLrf31mjBwGkh" required></div>
</center>
<input name="Send" class="button-contato" type="submit" id="Send" value="Enviar" required>
<br> <br>
<input name="Clear" class="button-contato" type="reset" id="Clear" value="Limpar">
<?php
if (isset($_POST[nome])){
$nome = $_POST[nome];
$facebook = $_POST[facebook];
$skype = $_POST[skype];
$discord = $_POST[discord];
$email = $_POST[email];
$mensagem = $_POST[mensagem];
$grecaptcha = $_POST[grecaptcha];
$assunto = "$_POST[nome], esta entrando em contato com voce. Assunto: $_POST[assunto]";
$send = ("$email_01"); //Coloque seu E-mail aqui.
$data = date("d/m/y");
$hora = date("H:i:s");
$ip = $_SERVER[REMOTE_ADDR];
$headers .= "From: $send\r\n";
//para o envio em formato HTML
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html;
charset=iso-8859-1\r\n";
$corpo =("
<b style=\"color:#000; font-size: 18px; font-weight: 600;\">Nome Completo: </b> <b style=\"color:#000; font-size: 16px;font-weight: 500;\"> $nome</b>
<br>
<b style=\"color:#000; font-size: 18px; font-weight: 600;\">Perfil Facebook: </b> <a href=\"$facebook\" style=\"color:#000; font-size: 16px;font-weight: 500;\">$facebook<a/>
<br>
<b style=\"color:#000; font-size: 18px; font-weight: 600;\">Contato Skype: </b> <b style=\"color:#000; font-size: 16px;font-weight: 500;\"> $skype </b>
<br>
<b style=\"color:#000; font-size: 18px; font-weight: 600;\">Contato Discord: </b> <b style=\"color:#000; font-size: 16px;font-weight: 500;\"> $discord </b>
<br>
<b style=\"color:#000; font-size: 18px; font-weight: 600;\">E-Mail: </b> <b style=\"color:#000; font-size: 16px;font-weight: 500;\"> $email</b>
<br><br>
<hr/>
<b style=\"color:#000; font-size: 18px; font-weight: 600;\">Mensagem: </b> <br> <b style=\"color:#000; font-size: 16px;font-weight: 500;\"> $mensagem</b>
<hr/>
<br><br>
<b style=\"color:red; font-size: 15px; font-weight: 600;\"> Data: $data <br/></b>
<b style=\"color:red; font-size: 15px; font-weight: 600;\"> Hora: $hora <br/></b>
<b style=\"color:red; font-size: 15px; font-weight: 600;\"> IP: $ip <br/></b>
");
mail($send, $assunto, $corpo, $headers);
echo "<script type=\"text/javascript\"> alert('$nome, Obrigado por entrar em contato comigo !! Logo mais entrarei em contato com você. Caso deseja um contato mais rapido, me chame pelas redes sociais. Grato !') </script>";
} else{
}
?>
</form>
I didn’t understand the reCaptcha API very well. Someone could do it for me ?
reCaptcha will pass you a key, which you will validate in Google’s webservice, using PHP
– Sveen
If the user does not perform captcha, the value passed by the form will be null. If reCaptcha loses validity, when checking in PHP, it will emit an error.
– Sveen
@Sveen that I understood. What I am not able to do and what, the person pass the form doing it
– zlDeath
Related: https://answall.com/q/268143/8063
– Sam
You’re just checking the name
if (isset($_POST[nome])){
, has to check the recaptcha as well– lazyFox