I have a contact form and I want to implement reCaptcha but the truth is that I have not been able to, I have tried but I can not get my PHP code to validate that the Captcha is not resolved and does not allow sending the form. Then my PHP and HTML code used.
In <head></head>
I have put as the official website says:
<script src='https://www.google.com/recaptcha/api.js'></script>
HTML:
<form action="enviar.php" method="post" enctype="multipart/form-data">
<h1 class="title">Contáctanos</h1>
<input name="name" required="required" placeholder="Nombre">
<br>
<input name="email" type="email" required="required" placeholder="Email">
<br>
<select name="enquirytype">
<option value="1">Publicar un Libro</option>
<option value="2">Error con Algún libro</option>
<option value="3">Otro error</option>
</select>
<br>
<textarea name="message" cols="20″ rows="5″ required="required" placeholder="Mensaje"></textarea>
<br>
<div class="g-recaptcha" data-sitekey="MiClaveAquí"></div>
<br>
<input id="submit" name="submit" type="submit" value="Submit">
</form>
PHP (send.php):
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: YourWebsite.com';
$to = '[email protected]';
$subject = 'Soporte Técnico - RelaxMind';
$ip = $_SERVER['REMOTE_ADDR'];
$select_enquirytype = strip_tags($_POST['enquirytype']);
$body = "From: $name\n E-Mail: $email\n Message:\n $message \n Option $select_enquirytype \n IP User: $ip";
?>
<?php
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Gracias, nos comunicaremos lo mas pronto posible!</p>';
} else {
echo '<p>Oh no! Hubo un error, Intenta mas tarde :(</p>';
}
}
?>
Saying that I have used it as it is in the ReCaptcha Help appears, only that I can not get PHP to validate that the Captcha was or was not resolved. That would be all my code, could you help me out? Thanks in advance.