PHP - Recaptcha en formulario html

 
Vista:
sin imagen de perfil

Recaptcha en formulario html

Publicado por eugeniocol (4 intervenciones) el 24/07/2017 11:54:28
Hola.

En formulario de contacto me salto la opción Captcha y envía el correo del formulario sin más???? el Captcha como tal funciona ok pero no hace nada en el envió de correo del formulario.

Que código funcionaria para que el correo no se mandara sin completar el ReCaptcha ¿?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
 
$mail='micorreo@yahoo.es';
 
 
$nombre = $_POST['nombre'];
$apellido = $_POST['apellido'];
$telefono = $_POST['telefono'];
$email = $_POST['email'];
$asunto = $_POST['asunto'];
$mensaje = $_POST['mensaje'];
$recaptcha = $_POST['g-recaptcha-responde'];
 
//$thank="gracias.html";
 
$message = "
nombre:".$nombre."
apellido:".$apellido."
telefono:".$telefono."
email:".$email."
asunto:".$asunto."
mensaje:".$mensaje."";
 
if (mail($mail,"Textoooooooooooooooooooooooo",$message))
//Header ("Location: $thank:");
header("Refresh: 3; URL=https://xxxxxxxxxxxxx.es/Emeil%20htlm%20Ok/gracias.html");
 
 
//Cambiar remitente correo
$cabeceras="From: <".$to."> \r\n";
$cabeceras.="Reply-To: <".$email."> \r\n";
$cabeceras .= 'MIME-Version: 1.0' . "\r\n";
$cabeceras .= 'Content-type: multipart/mixed' ."\r\n";
 
//$cabeceras .= "From: ".$_POST["mail"]."\r\n";
 
mail($email, $asunto, $mensaje, $cabeceras);
 
 
if(isset($_POST["g-recaptcha-responde"]) && $_POST["g-recaptcha-responde"])
{
  var_dump($_POST);
  $secret = "6LdvCyoUxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
  $ip = $_SERVER['REMOTE_ADDR'];
 
  $captcha = $_POST["g-recaptcha-responde"];
 
  $result = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$secret&response=$recaptcha&remoteip=$ip");
 
  echo "<br>";
  echo "<br>";
  echo "<br>";
  var_dump($result);
  $array = json_decode($result,TRUE);
  echo "<br>";
 
  if($array["success"])
  {
     echo "Eres humano";
  }else{
     echo "Eres un robot";
}
 
}
 
?>

Un Saludo.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder