Ver Mensaje Individual
  #3 (permalink)  
Antiguo 30/05/2008, 11:05
Avatar de T4ke0veR
T4ke0veR
 
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: Login de Usuarios -Pregunta Basica

archivo login.php
Código PHP:
<?php
include_once ('conect.php');
@
$valid=$_REQUEST['valid'];
if (
$valid==1){
$msj="El usuario o la clave que introdujo no son vàlidas. Por favor intente nuevamente!.";
}
?><table width="500" height="214" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="19" valign="top" class="text"><img src="imgs/header.jpg" width="500" height="100" /></td>
  </tr>
  <tr>
    <td height="184" valign="top" class="text"><p align="center" class="style7"><br />
      Secci&oacute;n Privada para Clientes</p>
      <p align="center" class="style10">&nbsp;</p>
  <form action="includes/login.php" method="post" name="login_form" id="login_form">
<table width="173" border="0" align="center">
            <tr>
              <td width="43" class="text"><span class="azulgrs_tah style10">Usuario</span></td>
              <td width="150"><input name="email" type="text" class="style10" value="" size="20" /></td>
            </tr>
            <tr>
              <td class="azulgrs_tah style10">Clave:</td>
              <td><input name="clave" type="password" class="style10" value="" size="20" /></td>
            </tr>
            <tr>
              <td class="text">&nbsp;</td>
              <td align="right">
                  <div align="right">
                    <input name="btn_aeptar" type="submit" class="style10" value="Aceptar" />
                  </div></td>
            </tr>
        </table>
        <p align="center"><span class="style10">Si Ud. es cliente de Partenon,<br />
ingrese su Usuario y Clave y   presione &quot;<span class="texto_marronosc_normal">Aceptar</span>&quot;</span></p>
  <p align="center">
            <?=$msj?></p>
      </form></td>
  </tr>
</table>
includes/login.php
Código PHP:
<?php
session_start
();
include 
"../conect.php";
$email strtolower ($_REQUEST["email"]);
$clave strtolower ($_REQUEST["clave"]);
//echo $email."....".$clave;
/*        
        $sql="select * from usuario"; //LOGIN DE USUARIOS
        $sql_exec = mysql_query($sql);
        //$rec = mysql_fetch_array($sql_exec);
        while($rec = mysql_fetch_array($sql_exec)){
        echo $rec['email']."---".$rec['clave']."<br>";
        }
*/


    
if(empty($email) or empty($clave)){
    
//error tipo: 1 campos vacios.
    
header("Location: ../login.php");
    }else{

        
$sql="select * from usuario where email='".$email."' and clave='".$clave."' "//LOGIN DE USUARIOS
        
$sql_exec mysql_query($sql);
        
$rec mysql_fetch_array($sql_exec);
        
//echo mysql_num_rows($sql_exec);
        //echo mysql_error();
                
if ($rec['email'] == $email  and $rec['clave'] == $clave  ){
                

                                    
$_SESSION['id']=$rec["id"];//ID DEL USUARIO
                                    
$_SESSION['nombre']=$rec["nombre"];//nombre del usuario
                                    
$_SESSION['email']=$rec["email"];//email
                                    
$_SESSION['id_tipo_usuario']=$rec["id_tipo_usuario"];//ID DEL USUARIO
 
                                    
header("Location: ../ficha_users.php");
                }else{ 
                
$msj="Error";
                
//error tipo: 2 usuarios no esta registrado en la base de datos    
                
header("Location: ../login.php");
                }
    }    
    
?>
y en tu panel de control o en toda pagina privada solo debes colocar esto

Código PHP:
<?php require_once('includes/sesion.php'); ?>
<?php 
require_once('conect.php'); ?>
<?php
$rec 
"-1";
if (isset(
$_SESSION['id'])) {
  
$rec $_SESSION['id'];
}
$sql="select * from usuario where id = '$rec'";
        
$sql_exec mysql_query($sql);
        
$rec mysql_fetch_array($sql_exec);
?>
espero t ayude..
saludos
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...