Jump to content


Photo

Erro De Session


  • Faça o login para participar
2 replies to this topic

#1 x_ENIGMA_x

x_ENIGMA_x

    Novato no fórum

  • Usuários
  • 5 posts
  • Sexo:Não informado

Posted 07/01/2005, 08:04

Estou tendo o seguinte erro:

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /xxx/xxx/admin/ver_usuarios.php:10) in /xxx/xxx/admin/restrito.php on line 2

Aqui está o código da página ver_usuarios.php:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Administração mjMusic.com.br</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="estilos.css" type="text/css">
</head>

<body>
<?
include "config.php";
include "restrito.php";

$db   = mysql_connect ($db_host, $db_user, $db_senha);
$basedados = mysql_select_db($db_name);

$sql = "SELECT * FROM `$tabela` order by id";
$resultado = mysql_query($sql);

include "menu.php";
?>

<table class="tabela" border="1" bordercolor="#efefef" cellpadding="1" cellspacing="1" width="600" align="center">
	<tr bgcolor="#efefef">
  <th>ID</th>
  <th>Nome</th>
  <th>Login</th>
  <th>Senha</th>
  <th>Email</th>
  <th>Editar</th>
  <th>Excluir</th>
	</tr>
<?
while ($linha = mysql_fetch_array($resultado)) {

$id = $linha["id"];
$nome = $linha["nome"];
$login = $linha["login"];
$senha = $linha["senha"];
$email = $linha["email"];

	echo "<tr><td>$id</td><td>$nome</td><td>$login</td><td>$senha</td><td>$email</td><td><a href='editar.php?id=$id'>editar</a></td><td><a href='excluir.php?id=$id'>excluir</a></td></tr>";
	}
?>
</table>
</body>
</html>

e aqui a página restrito.php:
<?php 
session_start(); 

if(!isset($_SESSION["usr"]) || !isset($_SESSION["pwd"])) 
{ 
    header("Location: index.php"); 
    exit; 
} 
?>

não sei se é necessário, mas aqui está a página que cria as sessions após preencher login e senha: verifica_login.php

<?
session_start();
include "config.php"; 

$db   = mysql_connect ($db_host, $db_user, $db_senha);
$basedados = mysql_select_db($db_name);

$login = $_POST["login"]; 
$senha = $_POST["senha"];

if(!$login || !$senha) 
{ 
    echo "Você deve digitar sua senha e login! <a href=javascript:history.go(-1)>Clique aqui para voltar.</a>"; 
    exit; 
} 

$resultado = mysql_query("SELECT * FROM mjusr WHERE login = '$login'"); 
$linhas = mysql_num_rows($resultado);

if($linhas==0) {
	echo "Usuário não encontrado!<br>";
	echo "Clique <a href='index.php'>aqui</a> para voltar.";
}
else  {
	if ($senha != mysql_result($resultado, 0, "senha")) {
	echo "Senha incorreta!<br>";
	echo "Clique <a href='index.php'>aqui</a> para voltar.";
	}
	else {
	$_SESSION["usr"]   = $login; 
    $_SESSION["pwd"] = $senha;
    header("Location: menu.php"); 
    exit; 
	}
}
mysql_close($db);
?>

alguem pode me ajudar? valeu!

#2 paes

paes

    GustavoPaes.Net

  • Usuários
  • 1393 posts
  • Sexo:Masculino
  • Localidade:São Paulo - SP
  • Interesses:Rumo ao topo!

Posted 07/01/2005, 09:06

tente assim na página ver_usuarios.php

<?
include "restrito.php";
include "config.php";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Administração mjMusic.com.br</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="estilos.css" type="text/css">
</head>

<body>
<?
$db   = mysql_connect ($db_host, $db_user, $db_senha);
$basedados = mysql_select_db($db_name);

$sql = "SELECT * FROM `$tabela` order by id";
$resultado = mysql_query($sql);

include "menu.php";
?>

<table class="tabela" border="1" bordercolor="#efefef" cellpadding="1" cellspacing="1" width="600" align="center">
<tr bgcolor="#efefef">
 <th>ID</th>
 <th>Nome</th>
 <th>Login</th>
 <th>Senha</th>
 <th>Email</th>
 <th>Editar</th>
 <th>Excluir</th>
</tr>
<?
while ($linha = mysql_fetch_array($resultado)) {

$id = $linha["id"];
$nome = $linha["nome"];
$login = $linha["login"];
$senha = $linha["senha"];
$email = $linha["email"];

echo "<tr><td>$id</td><td>$nome</td><td>$login</td><td>$senha</td><td>$email</td><td><a href='editar.php?id=$id'>editar</a></td><td><a href='excluir.php?id=$id'>excluir</a></td></tr>";
}
?>
</table>
</body>
</html>

Deve funcionar assim...
O que está acontecendo com o seu código é que o header() do restrito.php está ficando depois de algumas tags HTML... o que não pode...

O header() deve ficar ou antes de HTML ou em uma página somente com código PHP...

até mais
Site: GustavoPaes.net

^ Rumo ao Topo ^

#3 x_ENIGMA_x

x_ENIGMA_x

    Novato no fórum

  • Usuários
  • 5 posts
  • Sexo:Não informado

Posted 07/01/2005, 09:26

era isso mesmo cara!!! deu certo..

brigadão (y)




0 user(s) are reading this topic

0 membro(s), 0 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq