Problemas com session
session.php
<?php
session_start();
$conexao = mysql_connect('localhost','bruno','');
$db = mysql_select_db('cadastro');
if(isset($_SESSION['email']) || isset($_SESSION['senha']))
{
$email= $_SESSION['email'];
$senha=$_SESSION['senha'];
$nome = $_SESSION['nome'];
}
?>
pagina Painel.php
<body>
<div id="principal">
<div id="topo">
<div id="titulo">
<center><font size="6">Portal de Notícias</font></center>
</div>
<div id="menucadastro">
</div>
</div>
<div id="menulateralesquerda">
<br /><br />
<?php
/* if(!isset($_POST["email"]) || !isset($_POST["senha"]))
{
header('Location:index.php');
} */
if(isset($_POST["email"]) && isset($_POST["senha"]))
{
$email=$_POST['email'];
$senha=$_POST['senha'];
}
elseif(isset($_POST["email"]) && isset($_POST["senha"]) || isset($_GET['alt']) || isset($_GET['del']) || isset($_SESSION['email'])){
$email=$_SESSION['email'];
$senha=$_SESSION['senha'];
}
if(!isset($_POST["email"]) && !isset($_POST["senha"]) && !isset($_GET['alt']) && !isset($_GET['del']) && !isset($_SESSION['email']) ){
$email=$_SESSION['email'];
$senha=$_SESSION['senha'];
$naosetado=true;
}
if(isset($naosetado))
{
header('Location:index.php');
}
$BuscaEmaleSenha="SELECT * FROM cadastro WHERE email='$email' AND senha='$senha'";
$retornabuscaEmaileSenha=mysql_query($BuscaEmaleSenha);
$linha=mysql_fetch_assoc($retornabuscaEmaileSenha);
$nome=$linha['nome'];
$email2=$linha['email'];
$senha2=$linha['senha'];
$id=$linha['idCadastro'];
$_SESSION['nome'] = $nome;
if($senha!=$senha2 || $email != $email2 || empty($email) && empty($senha) || $senha=="" && $email=="")
{
?>
<center> <form action="" method="post" >
<table align="center">
<tr>
<td align="right">E-mail: </td><td><input type="text" name="email" class="texto" /></td>
</tr>
<tr>
<td align="right">Senha: </td><td><input type="password" name="senha" class="texto"/></td>
</tr>
<tr>
<th colspan="2">
<input type="submit" name="bt" value="Logar" />
</th>
</tr>
<tr>
<th colspan="2"><h2>Erro no Login </h2>
</th>
</tr>
</table>
</form></center>
<a href="index.php" class="link3">Inicio</a>
<?php
exit;
}
if($senha==$senha2 && $email == $email2 || isset($alterado))
{
$_SESSION['email'] = $email;
$_SESSION['senha'] = $senha;
?>
<table border="0">
<tr>
<th class="tabelalink"><a class="link2" href="index.php">Início</a> </th>
<th class="tabelalink"><a class="link2" href="painel.php">Painel</a> </th>
<th class="tabelalink"><a class="link2" href="sair.php?id=sair">Sair</a> </th>
</th>
</table>
<font color="#FFFFFF">Olá <?php echo "$nome"; ?> </font><br />
<h3 align="center"> Insira sua Notícia aqui</h3>Assunto:
<form action="" method="post" >
<select name="assunto">
<option value="Esporte">Esporte</option>
<option value="Tecnologia">Tecnologia</option>
<option value="Mundo">Mundo</option>
<option value="Economia">Economia</option>
<option value="Outros">Outros</option>
</select>
<br />
Título:<br />
<input type="text" maxlength="30" name="titulo" class="texto2"/>
<br />
<center>Descrição</center>
<textarea cols="25" rows="15" name="descricao" class="texto2"></textarea>
<br />
Link:<br />
<input type="text" maxlength="200" name="link" class="texto2"/>
<input type="hidden" name="data" value="<?php echo date('d/m/y'); ?>" />
<input type="submit" name="bt" value="Noticiar" />
</form>
<?php
if (isset($_POST['bt']) && $_POST['bt']=="Noticiar"){
$assunto2 = $_POST['assunto'];
$titulo2 = $_POST['titulo'];
$descricao2 = $_POST['descricao'];
$link2 = $_POST['link'];
$data2 = $_POST['data'];
$selecionacampos = "INSERT INTO noticias (idCadastro, assunto, titulo, descricao, link, data) VALUES ('$id', '$assunto2', '$titulo2' ,'$descricao2' ,'$link2', '$data2')";
if (empty($titulo2) || empty($descricao2) || empty($link2))
{echo "Preencha Todos os campos";}
else {
$insereNoticia= mysql_query($selecionacampos);
}
}
?>
</div>
<div id="noticias2">
<br /><br />
<?php
$selecionaTodasNoticias = "SELECT noticias.*, cadastro.* FROM cadastro, noticias WHERE cadastro.idCadastro=noticias.idCadastro AND email='$email' AND senha='$senha' order by idNoticias DESC";
$retornaTodasasNoticias = mysql_query($selecionaTodasNoticias);while ($linha=mysql_fetch_assoc($retornaTodasasNoticias))
{
$nome = $linha['nome'];
$titulo = $linha['titulo'];
$descricao = $linha['descricao'];
$link = $linha['link'];
$data = $linha['data'];
$idnoticias = $linha['idNoticias'];
?>
<table border="0" class="tabela">
<tr>
<th colspan="3"> <center><h1> <?php echo "$titulo"; ?></h1></center></th>
<td><p align="right"><font size="2" color="#FF0000"> <?php echo "$data"; ?></font><br /></p> </td>
</tr>
<tr>
<td colspan="4" width="100%"><font size="3" > <?php echo $descricao; ?> </td>
</tr>
<tr>
<th class="tabelalink"><a class="link2" href="<?php echo $link; ?>">Saiba mais!</a> <br/> </th>
<th class="tabelalink"><a class="link2" href="deletar.php?id=<?php echo $idnoticias;?>">Deletar Notícia</a></th>
<th class="tabelalink"><a class="link2" href="alterar.php?id=<?php echo $idnoticias;?>">Alterar Notícia</a></th>
<td align="right"><font size="2">Publicada por: <?php echo $nome;?></font> </td>
</tr>
</table>
<hr/>
<?php
}
?>
</div>
<?php
}
?>
</div>
na página painel esta dando este erro
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/ciscoene/public_html/avaliacao/painel.php:2) in/home/ciscoene/public_html/avaliacao/session.php on line 2
e a session funciona normalmente só está acontecendo este erro!
no incio do painel.php tem
<?php
include('session.php');
?>
Amigos, o site é esse, http://www.ciscoeneide.com.br/avaliacao/
este site é pra eu testar meus conhecimentos
Obrigado a todos.
Discussão (2)
Carregando comentários...