Ver Mensaje Individual
  #9 (permalink)  
Antiguo 04/05/2010, 11:31
Avatar de christianphp
christianphp
 
Fecha de Ingreso: mayo-2010
Ubicación: Rosario
Mensajes: 79
Antigüedad: 14 años
Puntos: 2
Respuesta: Salida de Logout en REQUIRE

Cita:
Iniciado por Heli0s Ver Mensaje
No veo ningun header("location: index.php"); por lo tanto creo que aún falta que me muestres código, de todos modos el problema es que no puede haber ninguna salida en pantalla antes de la función header, debe estar antes que cualquier etiqueta HTML.

Un saludo
Si perdon que lo puse mal

En el codigo del LOGIN es este que sale con: index.php y es ahí donde me tira el error de esa linea la 51

Código:
<?PHP
session_start();
function auth($user, $pass){
    $result = -1;

    if((trim($user) != "") && (trim($pass) != "")){
// make sure that the script has permission to read this file!
$data = file("admin/data/users.db.php");
    
// iterate through file
foreach ($data as $line){
    
    $arr = explode("|", $line);
    
    // if username matches
    // test password
    if($arr[2] == $user){

 // if match, user/pass combination is correct
// return 1
if($arr[3] == $pass){
    $result = 1;
    break;
}else{
    // otherwise return 0
    $result = 0;
    break;
}
   }
}
    }
    
    // return value
    return $result;
}

// Check if Sessions have exist or else see if any var's are posted
if(!isset($_SESSION["SESSION_UNAME"]) && !isset($_SESSION["SESSION_UPASS"])){
    $f_user = $_POST['f_user'];
    $f_pass = md5($_POST['f_pass']);
}else{
    $f_user = $_SESSION["SESSION_UNAME"];
    $f_pass = $_SESSION["SESSION_UPASS"];
}

if($_GET['logout'] == "true"){
    $f_user = "";
    $f_pass = "";
    session_unset();
    session_destroy();
    header("Location: index.php");
}

if(auth($f_user, $f_pass) == 1){
    $_SESSION["SESSION_UNAME"] = $f_user;
    $_SESSION["SESSION_UPASS"] = $f_pass;
}else{
echo <<<HTML
<html>
<head>
<title>Login</title>
</head>
<body>
<center>
<table border="0" cellspacing="5" cellpadding="5">
<form action="" method="POST">
<tr>
<td>Username</td>
<td><input type="text" size="20" name="f_user"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" size="20" name="f_pass"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" value="LogIn">
</td>
</tr>
</form>
</table>
</center>
</body>
</html>
HTML;
exit();
}
?>