Ver Mensaje Individual
  #4 (permalink)  
Antiguo 17/06/2008, 07:44
Avatar de carlosmbrizuela
carlosmbrizuela
 
Fecha de Ingreso: enero-2007
Ubicación: La Plata (Argentina)
Mensajes: 490
Antigüedad: 17 años, 3 meses
Puntos: 1
Respuesta: Problema con sesiones

<!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>
<title>Identificación de usuarios</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="verify-v1" content="7uiD5QdUtd0j14COc+V8QRQHTsLmS+qE5PWC/+OaSYQ=" />
<meta name="description" content="Identificación de usuarios">
<meta name="keywords" content="identificación, usuarios">
<meta name="revisit" content="1 semana">
<link href="estilo.css" type="text/css" rel="stylesheet" />
<script language="javascript" src="popup.js"></script>
<meta content="MSHTML 6.00.2800.1400" name="GENERATOR" />
<style type="text/css">
body
{
margin-left: 10px;
margin-top: 10px;
}
</style>
</head>

<?php
session_start();
$primeravez = FALSE;
if (empty(
$_POST["botEnviar"]))
{
$primeravez = TRUE;
$_POST["email"] = "";
$_POST["contrasena"] = "";
}
?>

<body bgcolor="#F5F5F5" topmargin="10">
<table width="836" cellpadding="0" cellspacing="0" border="0">
<tr>
<td colspan="2" width="836" height="30" bgcolor="#FFFFFF">Para poder acceder a su cuenta de usuario, debe identificarse. Si no está registrado, hagalo pulsando <a href="registro.php">aquí</a>.</td>
</tr>
<tr>
<td colspan="2" width="836" height="8" bgcolor="#FFFFFF"></td>
</tr>
<form name="login" method="post" action="login.php">
<tr>
<td width="100" bgcolor="#FFFFFF">Email *:</td>
<td width="736" bgcolor="#FFFFFF"><input name="email" type="text" id="email" value="<?php echo $_POST['email']; ?>" size="40" style="background-color:#F5F5F5" /></td>
</tr>
<?php
if (!$primeravez)
{
if (empty(
$_POST["email"]))
echo
"<tr><td colspan=\"2\" width=\"836\" height=\"25\" bgcolor=\"#FFFFFF\" style=\"color:#FF0000; font-size:14px\">¡Tiene que introducir su email!</td></tr>";
elseif (!
eregi("^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9_\-\.]+$", $_POST["email"]))
echo
"<tr><td colspan=\"2\" width=\"836\" height=\"25\" bgcolor=\"#FFFFFF\" style=\"color:#FF0000; font-size:14px\">¡Email no válido!</td></tr>";
else
$email = htmlspecialchars($_POST["email"]);
}
?>
<tr>
<td colspan="2" height="8" bgcolor="#FFFFFF"></td>
</tr>
<tr>
<td width="100" bgcolor="#FFFFFF">Contraseña *:</td>
<td width="736" bgcolor="#FFFFFF"><input name="contrasena" type="password" id="contrasena" value="<?php echo $_POST['contrasena']; ?>" size="40" style="background-color:#F5F5F5" /></td>
</tr>
<?php
if (empty($_POST["contrasena"]) && (!$primeravez))
echo
"<tr><td colspan=\"2\" width=\"836\" height=\"25\" bgcolor=\"#FFFFFF\" style=\"color:#FF0000; font-size:14px\">¡Tiene que introducir su contraseña!</td></tr>";
else
$contrasena = htmlspecialchars($_POST["contrasena"]);
?>
<tr>
<td colspan="2" width="836" height="8" bgcolor="#FFFFFF"></td>
</tr>
<tr>
<td colspan="2" width="836" bgcolor="#FFFFFF" align="center"><input name="botEnviar" type="submit" id="botEnviar" value="Enviar" style="width:100px; cursor:pointer" /></td>
</tr>
</form>
<?php
if ((!$primeravez) && isset($email) && isset($contrasena))
{
require_once(
"conexion.inc.php");
$conexion = mysql_connect($servidor, $usuario, $passwd);
$db = mysql_select_db($basedatos, $conexion);
if (!
$conexion)
{
echo
"Error al establecer la conexión con la base de datos: " . mysql_error();
exit();
}
if (!
$db)
{
echo
"Error seleccionando la base de datos: " . mysql_error();
exit();
}
$resultado = mysql_query("SELECT id_cliente FROM clientes WHERE email = '$email' AND contrasena = '$contrasena'", $conexion);
if (
mysql_num_rows($resultado) > 0)
{
$fila = mysql_fetch_array($resultado);

$_SESSION["usuario"] = $fila["id_cliente"];
$_SESSION["logged"] = TRUE;
echo
"<tr><td colspan=\"2\" width=\"836\" height=\"15\" bgcolor=\"#FFFFFF\"></td></tr><tr><td colspan=\"2\" width=\"836\" heigth=\"25\" bgcolor=\"#FFFFFF\" align=\"center\" style=\"color:#33CC00; font-size:14px\">Identificación realizada con éxito.</td></tr>";
}
else
{
echo
"<tr><td colspan=\"2\" width=\"836\" height=\"15\" bgcolor=\"#FFFFFF\"></td></tr><tr><td colspan=\"2\" width=\"836\" heigth=\"25\" bgcolor=\"#FFFFFF\" align=\"center\" style=\"color:#FF0000; font-size:14px\">¡Usuario o contraseña incorrectos!</td></tr>";
}
mysql_free_result($resultado);
mysql_close($conexion);
}
?>
</table>
</body>
</html>
__________________
http://www.rollermountain.com