Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá galera do iMasters, e o seguinte estou desenvolvendo um painel adm para um site, quando esse painel esta em localhost ele funciona normal sem nenhum erro, mas quando coloco ele online no servidor, ele me gera esse erro:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/hadassa/public_html/admin/index.php:1) in /home/hadassa/public_html/admin/index.php on line 37
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/hadassa/public_html/admin/index.php:1) in /home/hadassa/public_html/admin/index.php on line 37
eu não consegui solucionar esse erro se alguém poder me ajudar ficarei grato, vou colocar o meu código ai abaixo para vcs dar uma olhada.
INDEX.PHP
<?php require_once('../Connections/config.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['login'])) {
$loginUsername=$_POST['login'];
$password=$_POST['senha'];
$MM_fldUserAuthorization = "nivel";
$MM_redirectLoginSuccess = "painel.php";
$MM_redirectLoginFailed = "index.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_config, $config);
$LoginRS__query=sprintf("SELECT usuario, senha, nivel FROM hadassa_users WHERE usuario=%s AND senha=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $config) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'nivel');
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="CSS/style.css"/>
<title>Login | Hadassa Modas</title>
</head>
<?php//FAZ A CONEXÃO COM O MYSQL
$conexao = (mysql_connect("$hostname_config", "$username_config", "$password_config"))
or die (mysql_error());
$db = (mysql_select_db ("$database_config"))
or die (mysql_error());
?>
<body>
<div id="painel_de_login">
<div id="header_login_painel">
<div id="logo_login_painel"></div>
<div id="title_login"></div>
</div><!--Header login-->
<form method="POST" action="<?php echo $loginFormAction; ?>" name="login_error">
<fieldset>
<label>
<span id="user_name">Usuário</span>
<input type="text" name="login" id="user_campo" />
</label>
<label>
<span id="password_name">Senha</span>
<input type="password" name="senha" id="senha_campo" />
</label>
<input type="submit" name="logar" value="Logar-se" id="bt_logar_login" title="Clique para Fazer Login"/>
</fieldset>
</form>
</div><!--Painel de login-->
</body>
</html>
O erro pode estar aqui. Afinal, se não existir a sessão, você inicia ela? \o não vejo sentido nisso!
Crie um arquivo e coloque as configurações básicas do seu sistema, como: