PHP - Problemas con reCAPTCHA

   
Vista:

Problemas con reCAPTCHA

Publicado por jose (1 intervención) el 09/05/2017 21:15:51
Hola a tod@s.

Es la primera vez que entro en este foro.

Mi nombre es Jose y gracias de antemano por vuestro tiempo.

Veréis tengo una pagina hecha por mi y estoy recibiendo spam en el formulario de reservas. Estoy intentando poner reCAPTCHA pero parece que funciona pero en realidad siempre recibo el correo aunque no valides el reCAPTCHA incluso sin hacer click en el.

La web es esta: http://www.taxiorihuelacosta.com/pruebas.html#form

El html del form es este:
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<form name ="formularioContacto" action="ok.php" method="POST">
    <div class="form-group col-lg-2 img-thumbnail">
      <table width="130">
        <tr>
          <td class="text-nowrap">
            <label>FROM:</label>
          </td>
        </tr>
        <tr>
          <td class="text-left"><label>
            <input type="radio" name="RadioGroup1" value="Orihuela Costa" id="orihuela"  onclick="mostrar(this.form,0)">
            Orihuela Costa</label>
          </td>
        </tr>
        <tr>
          <td class="text-left"><label>
            <input type="radio" name="RadioGroup1" value="Alicante airport" id="alicante" onclick="mostrar(this.form,1)">
            Alicante airport</label>
          </td>
        </tr>
        <tr>
          <td class="text-left"><label>
            <input type="radio" name="RadioGroup1" value="Murcia airport" id="murcia" onclick="mostrar(this.form,1)">
            Murcia airport</label>
          </td>
        </tr>
      </table>
      <span class="help-block"></span>
    </div>
    <div class="form-group col-lg-2">
      <label for="flight">Number flight:</label>
      <input type="text" class="form-control" id="flight" name="flight" placeholder="flight">
      <span class="help-block"></span>
    </div>
    <div class="form-group col-lg-6">
      <label for="address">Full address:</label>
      <input type="text" class="form-control" id="address" name="address" placeholder="Full address">
      <span class="help-block"></span>
    </div>
    <div class="form-group col-lg-2">
      <label for="destination">Destination:</label>
      <input type="text" class="form-control" id="destination" name="destination" placeholder="Destination">
      <span class="help-block"></span>
    </div>
    <div class="form-group col-lg-3">
      <label for="date">Date:</label>
      <input name="date" type="date" class="form-control" id="date" placeholder="dd/mm/yyyy">
      <span class="help-block"></span>
    </div>
    <div class="form-group col-lg-2">
      <label for="time">Time:</label>
      <input name="time" type="time" class="form-control" id="time" placeholder="--:--">
      <span class="help-block"></span>
    </div>
    <div class="form-group col-lg-5">
      <label for="name">Full name:</label>
      <input type="text" class="form-control" id="name" name="name" placeholder="Full name">
      <span class="help-block"></span>
    </div>
    <div class="form-group col-lg-2">
      <label for="telephone">Telephone:</label>
      <input type="text" class="form-control" id="telephone" name="telephone" placeholder="Telephone">
      <span class="help-block"></span>
    </div>
    <div class="form-group col-lg-4">
      <label for="email">E-mail:*</label>
      <input name="email" class="form-control" type="email" id="email" placeholder="E-mail (Required)*">
      <span class="help-block"></span>
    </div>
    <div class="form-group col-lg-offset-0 col-lg-4">
      <label for="email_repeat">Repeat e-mail:*</label>
      <input name="email_repeat" class="form-control" type="email" id="email_repeat" placeholder="Repeat e-mail (Required)*">
      <span class="help-block"></span>
    </div>
    <div class="form-group">
      <div class="form-group col-lg-2">
        <label for="message">Nº Passengers:</label>
        <input type="number" class="form-control" name="passengers" id="passengers" placeholder="Nº Passengers">
        <span class="help-block"></span>
      </div>
      <div class="col-lg-4 col-lg-offset-4">
        <label for="message">Comments:</label>
      </div>
      <textarea rows="3" cols="100" class="form-control" id="message" name="message" placeholder="Comments"></textarea>
      <span class="help-block"></span>
    </div>
    <div class="containerform">
      <div class="colorformback col-lg-offset-0 col-lg-12">
        <input type="radio" onclick="habilita()"><label>ONLY MARK IF YOU WANT TO BOOK A TAXI FOR RETURN</label>
      </div>
      <div class="form-group col-lg-7">
        <label for="full address">Full address for return:</label>
        <input type="text" class="form-control" id="addressreturn" name="addressreturn" placeholder="Full address for return" disabled>
        <span class="help-block"></span>
      </div>
      <div class="form-group col-lg-3 col-lg-offset-0">
        <label for="date">Date for return:</label>
        <input name="datereturn" type="date" class="form-control" id="datereturn" placeholder="dd/mm/yyyy" disabled>
        <span class="help-block"></span>
      </div>
      <div class="form-group col-lg-2">
        <label for="time">Time for return:</label>
        <input name="timereturn" type="time" class="form-control" id="timereturn" placeholder="--:--" disabled>
        <span class="help-block"></span>
      </div>
      <div class="col-lg-4 col-lg-offset-4">
        <label for="message">Comments for return</label>
      </div>
      <textarea rows="3" cols="100" class="form-control" id="messagereturn" name="messagereturn" placeholder="Comments for return" disabled ></textarea>
    </div>
    <div class="g-recaptcha" data-sitekey="6Le1QSAUAAAAALJ5tZMIxWDVBbJC-e0ujOSidEHO"></div>
    <button type="reset" id="feedbackreset" class="btn btn-primary btn-lg"> Reset</button>
    <button type="submit" id="feedbackSubmit" class="btn btn-primary btn-lg"> Send</button>
</form>

y antes de </head> <script src='https://www.google.com/recaptcha/api.js'></script>

En el lado del servidor:
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
$orihuela = $_POST['RadioGroup1'];
$flight = $_POST['flight'];
$address = $_POST['address'];
$destination = $_POST['destination'];
$date = $_POST['date'];
$time = $_POST['time'];
$name = $_POST['name'];
$passengers = $_POST['passengers'];
$telephone = $_POST['telephone'];
$email = $_POST['email'];
$email_repeat = $_POST['email_repeat'];
$message = $_POST['message'];
$datereturn = $_POST['datereturn'];
$timereturn = $_POST['timereturn'];
$messagereturn = $_POST['messagereturn'];
 
$header .= 'From: ' . $email . " \r\n";
$header .= "X-Mailer: PHP/" . phpversion() . " \r\n";
$header .= "Mime-Version: 1.0 \r\n";
$header .= "Content-Type: text/plain";
 
$mensaje .= "From:" . $orihuela  . $alicante  . $murcia  . " \r\n";
$mensaje .= "Number flight: " . $flight . " \r\n";
$mensaje .= "Address: " . $address . " \r\n";
$mensaje .= "Destination: " . $destination . " \r\n";
$mensaje .= "Day: " . $date . " \r\n";
$mensaje .= "Hour: " . $time . " \r\n";
$mensaje .= "Name: " . $name . " \r\n";
$mensaje .= "Number passengers: " . $passengers . " \r\n";
$mensaje .= "Telephone: " . $telephone . " \r\n";
$mensaje .= "E-mail: " . $email . " \r\n";
$mensaje .= "E-mail2: " . $email_repeat . " \r\n";
$mensaje .= "Message: " . $message . " \r\n";
$mensaje .= "Day Return: " . $datereturn . " \r\n";
$mensaje .= "Hour Return: " . $timereturn . " \r\n";
$mensaje .= "Message Return: " . $messagereturn . " \r\n";
$mensaje .= "Enviado el " . date('d/m/Y', time('--:--'));
 
$para = 'bookings@taxiorihuela.com';
$asunto = 'Reservas TAXI';
 
 
mail($para, $asunto, utf8_decode($mensaje), $header);
 
 
 
function post_captcha($user_response) {
        $fields_string = '';
        $fields = array(
            'secret' => 'mi clave secreta',
            'response' => $user_response
        );
        foreach($fields as $key=>$value)
        $fields_string .= $key . '=' . $value . '&';
        $fields_string = rtrim($fields_string, '&');
 
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/siteverify');
        curl_setopt($ch, CURLOPT_POST, count($fields));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
 
        $result = curl_exec($ch);
        curl_close($ch);
 
        return json_decode($result, true);
    }
 
    // Call the function post_captcha
    $res = post_captcha($_POST['g-recaptcha-response']);
 
    if (!$res['success']) {
        // What happens when the CAPTCHA wasn't checked
        echo "<font color='red' <center> <font size=10>Please go back and make sure you check the security CAPTCHA box.</font>";
    } else {
        // If CAPTCHA is successfully completed...
 
        // Paste mail function or whatever else you want to happen here!
        echo "<font color='green' <center> <font size=10>Your order has been sent / / / Well be in touch soon / / / Best regards / / / TAXI Orihuela Costa.</font>";
    }
 
header( "refresh:4;http://www.taxiorihuelacosta.com/pruebas.html"  );
?>

Y nada lo dicho me llegan los correos tanto si verificas el reCAPTCHA como si no.

Gracias tod@s y saludos.
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
Revisar política de publicidad