yo uso este
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!.";
}
?>
<!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=iso-8859-1" />
<title></title>
<link href="style/CCS.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style5 {color: #666666}
.style6 {color: #333333}
.style7 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
.style9 {line-height: normal; font-weight: normal; text-align: left; height: auto; letter-spacing: normal; vertical-align: middle; word-spacing: normal; width: auto; left: auto; top: 5px; right: auto; bottom: auto; font-variant: normal; ´;font-style: normal;}
-->
</style>
<link href="estilos.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="46%" height="347" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="184" valign="top" class="text"><p align="center" class="style7"><span class="style9"><br />
</span></p>
<p align="center" class="azulgrs_tah">Sección Privada</p>
<p align="center" class="azulgris_verd_nrm">Bienvenido al Panel Adminstrativo Integral, coloque su usuario y clave para ingresar </p>
<form action="includes/login.php" method="post" name="login_form" id="login_form">
<p align="center"> </p>
<table width="200" border="0" align="center">
<tr>
<td width="61" class="text"><span class="azulgrs_tah">Usuario</span>:</td>
<td width="123"><input type="text" name="email" value="" /></td>
</tr>
<tr>
<td class="azulgrs_tah">Clave:</td>
<td><input type="password" name="clave" value="" /></td>
</tr>
<tr>
<td class="text"> </td>
<td align="right"><div align="center">
<input name="btn_aeptar" type="submit" class="TxSimple" value="Aceptar" />
</div></td>
</tr>
</table>
<p align="center">
<?=$msj?>
</p>
<p> </p>
<p> </p>
<p> </p>
</form></td>
</tr>
</table>
</body>
</html>
login.php <-en otra carpeta
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");
}
}
?>
saludos :)