Problema com header
Olá galera....
Seguinte, tenho um problema nos meus headers com os seguintes erros:
Caso o login digitado esteja errado a mensagem é: Warning: Cannot modify header information - headers already sent by (output started at /home/cobra12horas/www/restrito/index.php:5) in /home/cobra12horas/www/restrito/index.php on line 87 (linha do header de login inválido)...
Caso o login esteja correto:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/cobra12horas/www/restrito/index.php:5) in /home/cobra12horas/www/restrito/index.php on line 67
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/cobra12horas/www/restrito/index.php:5) in /home/cobra12horas/www/restrito/index.php on line 67
Warning: Cannot modify header information - headers already sent by (output started at /home/cobra12horas/www/restrito/index.php:5) in /home/cobra12horas/www/restrito/index.php on line 79
Detalhes: caso o login esteja correto, o erro fica na linha de redirecionamento para a pagina restrita....
e outra grande coisa é que na minha máquina funciona, mas no servidor externo é que tenho esse erro...
segue em anexo o código
<?php
include ("dbc.php");
$login = mysql_real_escape_string($_POST['login']);
if ($_POST['Submit']=='Entrar')
{
$md5pass = md5($_POST['pwd']);
$sql = "SELECT * FROM usuarios WHERE login = '$login' AND senha = '$md5pass' AND status='1' ";
$result = mysql_query($sql) or die (mysql_error());
$num = mysql_num_rows($result);
if (!$result){
header("Location: index.php?msg=Erro: Login Inválido");
//echo "Error:";
exit();
}
if ( $num != 0 ) {
$dados = mysql_fetch_object($result);
// A matching row was found - the user is authenticated.
session_cache_expire(1);
session_start();
$_SESSION['usuario']= $dados->login;
$_SESSION['permissao'] = $dados->permissao;
if (isset($_GET['ret']) && !empty($_GET['ret']))
{
header("Location: $_GET[ret]");
} else
{
if ($dados->permissao=='Administrador'){
header("Location: myaccount.php");
exit;
}
}
//echo "Logged in...";
}
header("Location: index.php?msg=Erro: Login Inválido");
//echo "Error:";
exit();
}
?>
<link href="styles.css" rel="stylesheet" type="text/css">
<?php if (($_GET['msg'])) {
echo "<div class=\"msg\"> $_GET[msg] </div>";
} ?>
Aguardo o retorno e agradeço desde já pela atençao...
Discussão (11)
Carregando comentários...