Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/05/2010, 08:52
Adrian967
 
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>