Foros del Web » Programando para Internet » PHP »

Ayuda para verificar codigo CAPTCHA

Estas en el tema de Ayuda para verificar codigo CAPTCHA en el foro de PHP en Foros del Web. Hola buenas tardes, quiero verificar un formulario entero y si, verifica el nombre, el email, el mensaje y el asunto. Lo que no verifica es ...
  #1 (permalink)  
Antiguo 01/05/2010, 08:52
 
Fecha de Ingreso: abril-2010
Mensajes: 9
Antigüedad: 14 años
Puntos: 0
Ayuda para verificar codigo CAPTCHA

Hola buenas tardes, quiero verificar un formulario entero y si, verifica el nombre, el email, el mensaje y el asunto. Lo que no verifica es el codigo captcha que si lo pongo bien dice codigo incorrecto y si lo pongo mal tambien dice codigo incorrecto. Que estoy haciendo mal? aqui dejo el codigo:

Código PHP:
<?php
session_start
();
if (isset(
$_POST['btget'])) {
// clean and check form inputs including the secure image code
    
$habboname trim(strip_tags($_POST['habboname']));
    
$asunto trim(strip_tags($_POST['asunto']));
    
$mail trim(strip_tags($_POST['mail']));
    
$mensaje trim(strip_tags($_POST['mensaje']));
    
$tmptxt strtoupper(trim(strip_tags($_POST['tmptxt'])));
    
$match $_SESSION['contacto']; // the code on the image

// input error checking
    
if ($habboname=="") {
        
$err.= "Pon tu habbonombre. En caso de no estar registrad@ en habbo.es, pon tu nombre.<br/>";
    }
    if (
$asunto=="") {
        
$err.= "Selecciona el asunto por el cual quieres contactarnos.<br/>";
    }
    if (!
$mail) {
        
$err.= "Pon tu verdadero E-mail.<br>";
    }
    if (
$mail) {
        if (!
eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"$mail)) {
            
$err.= $mail"Pon tu verdadera dirección de E-mail para poder contactar contigo.<br/>";
        }
    } 
    if (
$mensaje=="") {
            
$err.= "Escribe el mensaje.<br/>";
    }
    if (!
$tmptxt) {
        
$err.= "Escribe el código de seguridad.<br/>";
    }
    if ((
$tmptxt!=$action) && ($tmptxt!="")) {
        
$err.= "Código de seguridad incorrecto.<br/>";
    }
    if (
$err=="") {
    
// success - input passed all tests
    
echo "What you do with success is up to you.";
    exit();
    }
}
?>
<html>
<head>
 <SCRIPT language="JavaScript" type="text/javascript"> 
      <!-- 
    function refresh_image(image){
    tmp = new Date();
    tmp = "?"+tmp.getTime() 
    document.images["image_verify"].src = image+tmp 
}
      // --> 
      </SCRIPT>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CAPTCHA con PHP</title>
<meta name="description" content="CAPTCHA con PHP: ejemplo para demostrar la creacion de Captcha con PHP." />
<style type="text/css">
<!--
.style1 {
    font-family: Verdana;
    font-size: 11px;
}
-->
</style>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center" class="descdet">
    <div class="bordeder">
        <?php
if ($err!="") {
    echo 
"<font color='#cc3300'>"nl2br($err). "</font><br/>";
}
?>
        <form action="enviar.php" method="post" name="contacto">
                            <label><span class="style6">Habbo
Nombre:</span> <input name="habboname"
 id="login-username" size="30" type="text" value="<?php echo $_POST['habboname'];?>"/> </label>
                    <p> <label><span class="style6">Asunto:</span>
                    <select name="asunto" id="asunto" value="<?php echo $_POST['asunto'];?>"/>
                    <option selected="selected">Seleccione
el
asunto</option>
                    <option value="Afiliar WEB">Afiliar WEB</option>
                    <option value="Personal LN">Personal LN</option>
                    <option value="Sugerencias, etc... LN">Sugerencias,
etc... LN</option>
                    <option value="Personajes LN">Personajes
LN</option>
                    <option value="Peri&oacute;dico LN">Peri&oacute;dico
LN</option>
                    <option value="Chismes GossipWoman">Chismes
GossipWoman</option>
                    <option value="Mi Grupo LN">Mi Grupo LN</option>
                    </select>
                    </label> </p>
                    <p> <label><span class="style6">Tu
E-mail:</span> <input name="mail" id="mail"
 size="30" autocomplete="off" type="text" value="<?php echo $_POST['mail'];?>"/>></label></p>
                    <p> <label> <span class="style6">Mensaje:</span><br>
                    <textarea name="mensaje" cols="40"
 rows="8" id="mensaje"><?php echo $_POST['comments'];?></textarea></label></p>
<p><label>
          <img src="captcha.php" width="100" height="30" vspace="3" name="image_verify" id="image_verify"> <span class="style1"><a href="javascript:refresh_image('captcha.php');">Dadme Otro Código</a></span></label>
</p><br>
          <input name="tmptxt" type="text" size="30"><br>
          <input name="btget" type="submit" class="boton" value="Verificar Codigo">
          <input name="action" type="hidden" value="checkdata">
        </form>
    </div>
    </td>
  </tr>
</table>
</body>
</html>
  #2 (permalink)  
Antiguo 01/05/2010, 12:27
Avatar de dargor  
Fecha de Ingreso: octubre-2009
Mensajes: 134
Antigüedad: 14 años, 6 meses
Puntos: 2
Respuesta: Ayuda para verificar codigo CAPTCHA

aquí hay como generar un captcha y validarlo, talves te puede servir para comparar los pasos.

http://mundo-php.blogspot.com/2010/0...seguridad.html

Etiquetas: captcha, verificar
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:49.