Ver Mensaje Individual
  #4 (permalink)  
Antiguo 31/12/2008, 09:46
esaenz22
(Desactivado)
 
Fecha de Ingreso: abril-2008
Mensajes: 787
Antigüedad: 16 años
Puntos: 7
Respuesta: Web con varios formularios interconectados

hola letni. puedes hacer un archivo html para un formulario login y un archivo php k valide usuario y contraseña. te dejo el codigo para k lo revises.

index.html

Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="validar.php">
  <table width="305" border="0" align="center" cellpadding="2" cellspacing="1">
    <tr>
      <td width="74">Usuario</td>
      <td width="171"><input name="usuario" type="text" id="usuario" /></td>
      <td width="44">&nbsp;</td>
    </tr>
    <tr>
      <td>Clave</td>
      <td><input name="clave" type="password" id="clave" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><center><input type="submit" value="Ingresar" /></center></td>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>
</body>
</html>

validar.php

Código PHP:

    $cn 
= @mysql_connect("tu-servidor","tu-usuario",'tu-clave') or die("Error de conexion.");
        
mysql_select_db("tu-bd");
    
    
$sql_login "SELECT * FROM admin where usuario = '".$_POST['usuario']."'
                  and clave = '"
.$_POST['clave']."'";
                  
    
$rpta_login mysql_query($sql_login) or die(mysql_error());
    
        if(
mysql_num_rows($rpta_login)>0){ // si todo esta bien, redirecciona al archivo menu.php
            
$_SESSION['var_usuario'] = $_POST["usuario"];
            
$_SESSION['var_pass'] = $_POST["clave"];
            
            
header("Location:menu.php");
        
        }else{
//si no es correcto ni el usuario ni la clave, te redireccionara al index.html
            
header("Location:index.html");
        } 
menu.php

Código PHP:

           session_start
();
           
           echo 
"Bienvenido: ".$_SESSION['var_usuario']; 
saludos.