Ver Mensaje Individual
  #3 (permalink)  
Antiguo 09/01/2004, 17:00
SLandgren
 
Fecha de Ingreso: enero-2004
Mensajes: 3
Antigüedad: 20 años, 3 meses
Puntos: 0
gracias

lo hice y cambio, pero = no se muestra el mensaje de errror cuando existe ek error, puedo escribir algo, asi como un echo, el q si se muestra al existir el error, pero me gustaria hacer q este error apareciera al lado del textfield correspondiente, y no se me ocurre como hacerlo con echo, pq poner un if al lado de textfield es lo mismo q hize pero en otro orden........

Código PHP:
<?php
//Connection statement
require_once('Connections/db2.php');

//Aditional Functions
require_once('includes/functions.inc.php');

function 
Validar(){
$error="";
if(
comprobar_email($_POST['email'])){
    
$error="";
    return 
true;}
else {
    
$emilio=$_POST['email'];
    
$error="El email ".$emilio." es incorrecto";
    
    return 
false;}
}

function 
comprobar_email($email){ 
    
$mail_correcto 0
    
//compruebo unas cosas primeras 
    
if ((strlen($email) >= 6) && (substr_count($email,"@") == 1) && (substr($email,0,1) != "@") && (substr($email,strlen($email)-1,1) != "@")){ 
       if ((!
strstr($email,"'")) && (!strstr($email,"\"")) && (!strstr($email,"\\")) && (!strstr($email,"\$")) && (!strstr($email," "))) { 
          
//miro si tiene caracter . 
          
if (substr_count($email,".")>= 1){ 
             
//obtengo la terminacion del dominio 
             
$term_dom substr(strrchr ($email'.'),1); 
             
//compruebo que la terminación del dominio sea correcta 
             
if (strlen($term_dom)>&& strlen($term_dom)<&& (!strstr($term_dom,"@")) ){ 
                
//compruebo que lo de antes del dominio sea correcto 
                
$antes_dom substr($email,0,strlen($email) - strlen($term_dom) - 1); 
                
$caracter_ult substr($antes_dom,strlen($antes_dom)-1,1); 
                if (
$caracter_ult != "@" && $caracter_ult != "."){ 
                   
$mail_correcto 1
                } 
             } 
          } 
       } 
    } 
    if (
$mail_correcto==1
       return 
true
    else 
       return 
false



if (isset(
$_POST['Submit']) && Validar()){

// build the form action
$editFormAction $HTTP_SERVER_VARS['PHP_SELF'] . (isset($HTTP_SERVER_VARS['QUERY_STRING']) ? "?" $HTTP_SERVER_VARS['QUERY_STRING'] : "");

if ((isset(
$HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
  
$insertSQL sprintf("INSERT INTO formulario (apellido, email) VALUES (%s, %s)",
                       
GetSQLValueString($HTTP_POST_VARS['nombre'], "text"),
                       
GetSQLValueString($HTTP_POST_VARS['email'], "text"));

  
$Result1 $db2->Execute($insertSQL) or die($db2->ErrorMsg());
}

}

// begin Recordset
$query_rs_chica "SELECT apellido, email FROM formulario";
$rs_chica $db2->SelectLimit($query_rs_chica) or die($db2->ErrorMsg());
$totalRows_rs_chica $rs_chica->RecordCount();
// end Recordset

//PHP ADODB document - made with PHAkt 2.6.0
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form action="<?php echo $editFormAction?>" name="form1" method="POST">
  
  <table width="50%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td>Nombre</td>
      <td>
<input name="nombre" type="text" id="nombre"></td>
    </tr>
    <tr>
      <td>Email</td>
      <td><input name="email" type="text" id="email"><?php echo $error;?></td>
    </tr>
    <tr>
      <td>
<input type="submit" name="Submit" value="Submit"></td>
      <td>&nbsp;</td>
    </tr>
  </table>
  
  <input type="hidden" name="MM_insert" value="form1">
</form>
</body>
</html>
<?php
$rs_chica
->Close();
?>