Ver Mensaje Individual
  #11 (permalink)  
Antiguo 26/05/2011, 07:11
gordot
 
Fecha de Ingreso: febrero-2010
Ubicación: cba
Mensajes: 203
Antigüedad: 14 años, 3 meses
Puntos: 16
Respuesta: ¿Como integrar reCaptcha en un formulario?

tienes que poner esto en el html donde esta al formulario para que te muestre el capchta:

Código PHP:
<label for='message'>Ingrese el código de seguridad:</label><br>
<img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' style="float: left;" />
<input id="6_letters_code" name="6_letters_code" type="text" style="margin:15px 0px 0px 0px;">
<div style="margin: 10px 0px 0px 0px ;">
<small >¿No puede leer la imagen? click <a href='javascript: refreshCaptcha();'>aquí</a> para recargar</small>
</div>
</p>
<div id="error">
    </div><?php
if(!empty($errors)){
echo 
"<p class='err'>".nl2br($errors)."</p>";
}
?>
<div id='contact_form_errorloc' class='err'></div>
y en el php hice unas modificaciones:

Código PHP:
<?php 

session_start
();
$errors '';
if(isset(
$_POST['submit'])) 

  if(empty(
$_SESSION['6_letters_code'] ) || 
    
strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0
  { 
      
//Note: the captcha code is compared case insensitively. 
      //if you want case sensitive match, update the check above to 
      // strcmp() 
    
$errors .= "\n The captcha code does not match!"
  } 
  
  if(empty(
$errors)) 
  { 
    
//send the email 
    
$to $your_email
    
$subject="New form submission"
    
$from $your_email
    
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''
  
    
"$body = "A user  $_POST['field_1'submitted the contact form:n". 
    " 
· Contact Name$_POST['field_1']n". 
    " 
· Phone Number$_POST['field_2'n". 
    " 
· Email$_POST['field_3'n". 
    " 
· Number of people$_POST['field_4'n". 
    " 
· Kind of service$_POST['field_5'n". 
    " 
· Hour of pick up:  $_POST['field_6'n". 
    " 
· Place of pick up$_POST['field_7'n". 
    " 
· Needs". 
    "
$_POST['field_8']n". 
    "
IP$ipn";  
  
    $headers = "
From$from rn"; 
    $headers .= "
Reply-To$visitor_email rn"; 
  
    mail($to, $subject, $body,$headers); 
  
    header('Location: confirm.html'); 
  } 



?>
tambien acuerdate de poner estos scripts en el head:
<script language="JavaScript" src="scripts/gen_validatorv31.js" type="text/javascript"></script>

<script language='JavaScript' type='text/javascript'>
function refreshCaptcha()
{
var img = document.images['captchaimg'];
img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?ra nd="+Math.random()*1000;
}
</script>


dime como te fue asi lo hacemos funcionar