Ver Mensaje Individual
  #3 (permalink)  
Antiguo 04/05/2010, 09:28
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
Si no pones código es más difícil ayudarte... de todas formas ese error es típico de poner session_start() después de una salida de código HTML, o de usar setcookie después de una salida de código HTML.


Un saludo
Hola amigo gracias por responderme si pongo codigo es muy largo imaginate lleva requires, me sirvio puse el Login arriba de todo de la cabecera y funciona exelentemente con su LOGOUT y no tira error pero lo que pasa es que antes de loguearte a la web no se ve nada o sea sale solo LOGIN CONTRASEÑA.


ESTE ES EL CODE DEL LOGIN
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: ?");
}

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();
}
?>
Y ASI LA PARTE DEL LOGOUT QUE INCLUDE AL CODIGO ANTERIOR:

Código:
<?PHP include("auth.inc.php"); ?>
<a href="?logout=true">Logout</a>

Mi pregunta es como puedo poner ese LOGIN EN EL MENU sin que restrinja la web...