Tema: formularios
Ver Mensaje Individual
  #6 (permalink)  
Antiguo 13/03/2007, 15:48
Avatar de gerson
gerson
 
Fecha de Ingreso: febrero-2005
Ubicación: Lima
Mensajes: 481
Antigüedad: 20 años
Puntos: 4
Re: formularios

Pues para tal caso tienes que hacer todo en la misma pagina.

Este ejemplo es sencillo, puedes mejorarlo logicamente..
Código PHP:
if(isset($_GET['accion']) && ($_GET['accion'] == 'reg') ){
    if (
FunValidarDatos()){
        
header("Location: pag_signuiente.php");
    }
}

global 
$error;
function 
FunValidarDatos(){
    global 
$error;
    if (isset(
$_POST['email'])){
        
//buscas en la BD si el mail esta registrado ejemplo
        
if($_POST['email'] == '[email protected]'){
            
$error 'email registrado';
            return 
false;
        }else{
            return 
true;
        }
    }
}
function 
FunInputText($nombre,$valor '',$parametros '',$ins_valor false) {
    
$text '<input type="text" name="' $nombre '"';    
    if ((
$ins_valor == true) && (isset($GLOBALS[$nombre]))) {
        
$text .= ' value = "' stripslashes(htmlspecialchars($GLOBALS[$nombre])) . '"';
    }elseif (
$valor != '') {
        
$text .= ' value ="' htmlspecialchars($valor) . '"';
    }
    if (
$parametros != '') {
        
$text .= ' ' $parametros;
    }
    
$text .= '>';
    return 
$text;
}
echo 
$error;
echo 
'
<form name="form1" method="post" action="test.php?accion=reg">
nombre: ' 
FunInputText('nombre','','',true) . '<br>
email: ' 
FunInputText('email','','',true) . '<br>
telefono: ' 
FunInputText('telefono','','',true) . '<br>
<input type="submit" value="registrar">
</form>'

Espero q te ayude....

Salu2
__________________