Ver Mensaje Individual
  #4 (permalink)  
Antiguo 14/04/2011, 06:02
pep0te
 
Fecha de Ingreso: agosto-2010
Mensajes: 81
Antigüedad: 13 años, 8 meses
Puntos: 3
Respuesta: Manejo de sesiones - Qué hacer...

Hola,

No sé cuál es la razón, pero tengo un .php de login (el que he dicho antes) y al darle al botón para comprobar si existe algún usuario recorriendo la DB, aunque no ponga nada o ponga algo mal, entra igualmente. Pongo el código:

Código PHP:
<?php
ob_start
();
session_start();
include(
"config.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
</head>
<body>
<?php
    
if (!isset($_SESSION['username']) || !isset($_SESSION['privilegios']) || !isset($_SESSION['id'])) {
       
session_destroy();
    }else{
       echo 
"<script language=\"javascript\">window.location.href = \"portada.php?modulo=list\";</SCRIPT>";
       return 
false;
    }
    if(!empty(
$_POST['check'])) {
       
$busca mysql_query("SELECT n_socio, password, privilegios FROM usuarios WHERE username = '".$_POST['user']."' AND password = '".$_POST['password']."' AND activo = '0'");
       
$numbusca mysql_num_rows($busca);
       
$dato mysql_fetch_assoc($busca);
       if (
$numbusca != 0) {
            
session_start();
            
$_SESSION['id']=$dato['n_socio'];
            
$_SESSION['username']=$_POST['user'];
            
$_SESSION['privilegios']=$dato['privilegios'];
            echo 
"<script language=\"javascript\">window.location.href = \"portada.php?modulo=list\";</SCRIPT>";
       }else{
            
$error.='Datos incorrectos o usuario sin confirmar.';
       }
    }
?>
<center>
<table id="login">
    <form action="portada.php?modulo=list" method="POST">
        <tr>
            <td>Usuario:</td><td><input type="text" name="user" maxlength="15" style="width:181px; height:14px; padding-left:2px; padding-right:0px;" /></td>
        </tr>
        <tr>
            <td>Password:</td><td><input type="text" name="password" maxlength="15" style="width:181px; height:14px; padding-left:2px; padding-right:0px;" /></td>
        </tr>
        <tr>
            <td colspan="2" align="center"><input type="submit" name="check" value="Login"></td>
        </tr>
        <tr>
            <td colspan="2">
                <?php
                    
echo ''.$error.'';
                 
?>
            </td>
        </tr>
    </form>        
</table>
</center>
</body>
Es un poco coñazo, pero no sabía cómo ponerlo. ¿Veis algo extraño?