Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\l2painel\val\validacao.php:1) in C:\AppServ\www\l2painel\val\validacao.php on line 25
Uma pequena contribuicao,
VALIDACAO.PHP
<?php
if (!isset($_SESSION)) session_start();
include('../config/config.php');
// Verifica se houve POST e se o usuário ou a senha é(são) vazio(s)
if (!empty($_POST) AND (empty($_POST['usuario']) OR empty($_POST['senha']))) {
echo '<script type="text/javascript">window.location="../index.php?erro=em_branco";</script>';
//header("Location: ../index.php?erro=em_branco"); exit;
}
$usuario = mysql_real_escape_string(trim($_POST['usuario']));
$senha = base64_encode(pack('H*', sha1($_POST['senha'])));
// Validação do usuário/senha digitados
$sql = "SELECT * FROM `accounts` WHERE (`login` = '". $usuario ."') AND (`password` = '". $senha ."') LIMIT 1";
$query = mysql_query($sql);
if (mysql_num_rows($query) != 1) {
echo '<script type="text/javascript">window.location="../index.php?Pagina=loginerror";</script>';
//header("Location: ../index.php?Pagina=loginerror"); exit;
} else {
// Salva os dados encontados na variável $resultado
$resultado = mysql_fetch_assoc($query);
// Se a sessão não existir, inicia uma
//if (!isset($_SESSION)) session_start();
// Salva os dados encontrados na sessão
$_SESSION['UsuarioLogin'] = $resultado['login'];
$_SESSION['UsuarioNome'] = $resultado['nome'];
$_SESSION['UsuarioNivel'] = $resultado['access_level'];
$_SESSION['UsuarioEmail'] = $resultado['email'];
// Redireciona o visitante
if($_SESSION['UsuarioNivel'] == "1"){
echo '<script type="text/javascript">window.location="../index.php?Pagina=administracao";</script>';
// header("Location: ../index.php?Pagina=administracao"); exit;
}
if($_SESSION['UsuarioNivel'] == "0"){
echo '<script type="text/javascript">window.location="../index.php?Pagina=painel";</script>';
// header("Location: ../index.php?Pagina=painel"); exit;
}
}
?>
<?php
:)