Ver Mensaje Individual
  #7 (permalink)  
Antiguo 13/07/2011, 11:20
jose-web
 
Fecha de Ingreso: enero-2009
Ubicación: Tijuana
Mensajes: 80
Antigüedad: 17 años, 9 meses
Puntos: 2
Respuesta: Cual es el mejor formulario de PHP con algun Captcha?

Cita:
Iniciado por abimaelrc Ver Mensaje
¿Cómo lo haz hecho? Porque si llega spam es porque algo estás haciendo mal o lo que usaste está mal.
Este era mi formulario:
claro ya viene incluido las librerias.

A ver que opinas:

mail.php

Código HTML:
<form id="form1" name="form1" method="post" action="thanksre.php"> 
<table width="450" border="0" align="center" cellpadding="0" cellspacing="0" class="text-panel"> 
<tr>
  <td width="139">Name:</td>
  <td width="10">&nbsp;</td>
  <td width="305"><label for="name"></label>
    <input type="text" name="name" id="name"></td>
</tr>
<tr>
  <td>Address:</td>
  <td>&nbsp;</td>
  <td><label for="address"></label>
    <input type="text" name="address" id="address"></td>
</tr>
<tr>
  <td>City/State</td>
  <td>&nbsp;</td>
  <td><label for="city_state"></label>
    <input type="text" name="city_state" id="city_state" /></td>
</tr>
<tr>
  <td>Phone:</td>
  <td>&nbsp;</td>
  <td><label for="phone"></label>
    <input type="text" name="phone" id="phone"></td>
</tr>
<tr>
  <td>Facial Procedures:</td>
  <td>&nbsp;</td>
  <td><label for="facial_procedures"></label>
    <label for="facial_procedures"></label>
    <textarea name="facial_procedures" id="facial_procedures" cols="45" rows="5"></textarea></td>
</tr>
<tr>
  <td>Breast Procedures</td>
  <td>&nbsp;</td>
  <td><label for="breast_procedures"></label>
    <textarea name="breast_procedures" id="breast_procedures" cols="45" rows="5"></textarea></td>
</tr>
<tr>
  <td>Body Procedures</td>
  <td>&nbsp;</td>
  <td><label for="body_procedures"></label>
    <textarea name="body_procedures" id="body_procedures" cols="45" rows="5"></textarea></td>
</tr>
<tr>
  <td>Email:</td>
  <td>&nbsp;</td>
  <td><label for="email"></label>
    <input type="text" name="email" id="email"></td>
</tr> 
<tr> 
  <td>&nbsp;</td>
  <td>&nbsp;</td> 
  <td><?php 
// Require reCAPTCHA lib 
require_once('recaptchalib.php'); 
// Your public key you get this from signup page 
$publickey = "6Le5_MISAAAAAKavlin2lQ-3OTYVkBDAyXYCprbH"; 
echo recaptcha_get_html($publickey); 
?></td> 
</tr> 
<tr>
  <td>Comments:</td>
  <td>&nbsp;</td>
  <td><label for="comments"></label>
    <textarea name="comments" id="comments" cols="45" rows="5"></textarea></td>
</tr>
<tr> 
<td>&nbsp;</td>
<td>&nbsp;</td> 
<td><input type="submit" name="submit" id="submit" value="Submit" /></td> 
</tr> 
</table> 
</form> 
thanksre.php

Código PHP:
<?php 
// Check if submit button has been submitted 
if (isset($_POST['submit'])){ 
// Include reCAPTCHA lib 
require_once('recaptchalib.php'); 
// Your private key goes here between quotes 
$privatekey = "6Le5_MISAAAAAKe-Nd6MRZEQ44XOYvm9CHWrZ8EX"; 
$resp = recaptcha_check_answer ($privatekey, 
$_SERVER["REMOTE_ADDR"], 
$_POST["recaptcha_challenge_field"], 
$_POST["recaptcha_response_field"]); 
if (!
$resp->is_valid) { 
// What happens when the CAPTCHA was entered incorrectly 
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . 
"(reCAPTCHA said: " . $resp->error . ")"); 
} else { 
// Put here what would happen if words are entered correctly 
$name = $_POST['name'];
           
$address = $_POST['address'];
           
$city_state = $_POST['city_state'];
           
$phone = $_POST['phone'];
           
$facial_procedures = $_POST['facial_procedures'];
           
$breast_procedures = $_POST['breast_procedures'];
           
$body_procedures = $_POST['body_procedures'];
           
$email = $_POST['email'];
           
$comments = $_POST['comments'];
                      
                     
            
//Estoy recibiendo el formulario, compongo el cuerpo 
            
$cuerpo .= "Name:    " . $name . "\n"; 
            
$cuerpo .= "Address: " . $address . "\n";
            
$cuerpo .= "City/State: " . $city_state . "\n";
            
$cuerpo .= "Facial Procedures: " . $facial_procedures . "\n";
            
$cuerpo .= "Breast Procedures: " . $breast_procedures . "\n";
            
$cuerpo .= "Body Procedures: " . $body_procedures . "\n";
            
$cuerpo .= "Phone:      " . $phone . "\n"; 
            
$cuerpo .= "Email:       " . $email . "\n"; 
            
$cuerpo .= "Comments: " . $comments . "\n";  
            
            
            
//$cuerpo .= 'Archivo: <a href="'.$url.'images/'.$userfile.'">'.$userfile.'</a>';
        
            //mando el correo...   
            
mail("[email protected]","Titulo",$cuerpo);  //
            
header('Location: http://'.getenv('HTTP_HOST').'/thanksre.php');
//echo "You have entered reCAPTCHA words correctly, your entered text is: ".$_POST['text']."";
} 
} 
?>