Ver Mensaje Individual
  #17 (permalink)  
Antiguo 05/06/2010, 04:02
veronica21
 
Fecha de Ingreso: junio-2009
Mensajes: 103
Antigüedad: 15 años, 9 meses
Puntos: 0
Respuesta: Problema con variable de sesion

Bueno pues asi queda ahora la estructura:




login o registrate:

<?php

if( !empty($_POST['logueo']) )
{
if(!empty($_POST['logueo']) && !empty($_POST['login']) && !empty($_POST['password']))
{
//conexion bd
@include(conexionbd);

$usuario = $_POST['login'];
$pass = $_POST['password'];

//Consultamos dentro de la base de datos para comprobar si existe el usuario
$login = "SELECT * FROM USUARIO WHERE login='$usuario' and password='$pass'";
$result = $mysqli->query($login);

$contador = 0;
while( $fila = $result->fetch_row() )
{
//aqui entrara si el usuario esta en la base de datos y si es usuario normal
if($usuario == $fila[0] && $pass == $fila[1] && $fila[9] == '0' && $fila[10] == '1')
{
$contador++;

$_SESSION['name'] = $usuario;
$_SESSION['user'] = "usuario";
$_SESSION['privilegio'] = 0;
header("Location: ../usuario/index.php?page=compra");
}

//entra si esta en la base de datos y si es administrador
else if($usuario == $fila[0] && $pass == $fila[1] && $fila[9] == '1' && $fila[10] == '1')
{
$contador++;

//la variable admincantbuy se utilizara en el index de administracion para decirle al usuario que no puede comprar siendo administrador
$_SESSION['admincantbuy'] ="admincantbuy";
$_SESSION['name'] = $usuario;
$_SESSION['privilegio'] = 1;
$_SESSION['user'] = "administrador";
header("Location: ../management/index.php");
exit;
}
//si no esta en la base de datos muestra el siguiente mensaje
}
//si no esta en la base de datos muestra el siguiente mensaje
if( $contador == 0 )
{
if( $fila[10] == '0' )
{
?> <SCRIPT LANGUAGE='javascript'> alert('TU CUENTA SE ENCUENTRA SUSPENDIDA, PORFAVOR, CONTACTE CON EL ADMINISTRADOR'); </SCRIPT> <?php
}
else
{
?> <SCRIPT LANGUAGE='javascript'> alert('El usuario o password introducidos son incorrectos'); </SCRIPT> <?php
}
}
$mysqli->close();
}//cierra if empty
else
{
if(!empty($_POST['logueo']))
{
echo "<SCRIPT LANGUAGE='javascript'> alert('Porfavor, no deje en blanco ninguno de los campos'); </SCRIPT>";
}
}
}
?>

<STYLE>
.wrapper
{
margin: 1em;
}
.contenedor_login
{
width: 43%;
border: 1px solid black;
border-radius: 5px;
-moz-border-radius: 4.5px;
float:right;
padding: 1em;
}
.tituloo
{
font-weight:bold;
border-bottom: 1px solid black;
margin-bottom: 1em;
}
.contenedor_registrate
{
width: 45%;
border: 1px solid black;
border-radius: 5px;
-moz-border-radius: 4.5px;
float:right;
margin-right: 0.5em;
padding: 1em;
}

</STYLE>



<!-- LOGIN -->
<DIV class='titulo'> LOGIN </DIV>
<DIV CLASS='wrapper'>
<DIV CLASS='contenedor_login'>
<DIV CLASS='tituloo'> YA ERES USUARI@ REGISTRAD@? </DIV>

<FORM METHOD='POST'>
LOGIN: <BR><INPUT TYPE='TEXT' NAME='login' SIZE='14'><BR>
CONTRASEÑA: <BR><INPUT TYPE='password' NAME='password' SIZE='14'><BR>
<IMG SRC=../photoshop/registro.jpg width=50px height=50px alt='registrate'><INPUT TYPE='SUBMIT' NAME='logueo' VALUE='Enviar'><BR>
</FORM>

</DIV>




<!-- REGISTRATE -->
<DIV CLASS='contenedor_registrate'>
<DIV CLASS='tituloo'> CREA TU CUENTA </DIV>
Soy nuev@ client@ y quiero crear mi nueva cuenta.

Al crear una cuenta en <B>Doitfast</B> podrás realizar tus compras cómodamente y de forma fácil<br>
<FONT COLOR='red'><A HREF='index.php?page=registrate' style={border:none;}>Pulsa aquí para crear tu cuenta</A> </FONT>

</DIV>


<!-- CIERRA WRAPPER -->
</DIV>






mangement:


<?php
session_start();


//definimos la ruta donde se encuentra el archiv conexion con el conectaremos con la bd para reducir codigo
define('conexionbd','../conexion/conexion.php');



if(!empty($_SESSION['admincantbuy']))
{
unset($_SESSION['admincantbuy']);
?> <SCRIPT LANGUAGE='javascript'> alert('NO PUEDES COMPRAR SIENDO ADMINISTRADOR, PORFAVOR HAZTE UN USUARIO NORMAL'); </SCRIPT> <?php
}

if(!empty($_SESSION['user']) && !empty($_SESSION['name']))
{
if($_SESSION['user'] == 'administrador')
{
?>

<!-- CUERPO -->
<DIV class='contenedor'>

<!-- LOGO PRINCIPAL -->
<?php
@include("includes/baner.php");
?>


<!-- SECCION IZQUIERDA -->
<?php
@include("includes/seccion_izquierda.php");
?>


<!-- SECCION CENTRO -->
<DIV CLASS='centro'>
<DIV CLASS='menu'>

<?php

if(empty($_GET['page']))
{
@include("includes/centro/newarticulo.php");
}
else
{
$page = $_GET['page'];
@include("includes/centro/".$page.".php");
}

?>
</DIV>
</DIV>

<!-- SECCION DERECHA -->
<?php
@include("includes/seccion_derecha.php");
?>

</DIV>

<?php

}
else
{
header("Location: ../errores/error.php?error=2");
}

}
else
{
header("Location: ../errores/error.php?error=2");
}



?>
<HTML>

<HEAD>

<TITLE> Administracion </TITLE>
<link rel='stylesheet' type='text/css' href='../css/recursos.css'>
<link rel='stylesheet' type='text/css' href='../css/articulos_carrito.css'>


</HEAD>

</HTML>