Ok, quello citato nel titolo è un errore frequente, dovuto magari al posizionamento errato di session_start() o a spazi che precedono la funzione.. ma nel mio caso mi dice che l' header è già iniziato da un file css.. Come è possibile? Il file è tutto codici css, la pagina in cui compare l' errore header è la seguente (ho lasciato solo i codici importanti):
Codice PHP:
<?php
/*---------------------------------------------------+
| MyBeatCMS - Powered by zypp0
+----------------------------------------------------+
| Copyright © 2011 Zypp0 & Meth0d
+---------------------------------------------------*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>MyBeat ~ Registrazione</title>
<link rel="stylesheet" href="http://images.habbo.com/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/572/web-gallery/static/styles/common.css" type="text/css" />
<script src="http://images.habbo.com/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/572/web-gallery/static/js/libs2.js" type="text/javascript"></script>
<script src="http://images.habbo.com/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/572/web-gallery/static/js/visual.js" type="text/javascript"></script>
<script src="http://images.habbo.com/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/572/web-gallery/static/js/libs.js" type="text/javascript"></script>
<script src="http://images.habbo.com/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/572/web-gallery/static/js/common.js" type="text/javascript"></script>
<link rel="stylesheet" href="http://images.habbo.com/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/572/web-gallery/static/styles/quickregister.css" type="text/css" />
<script src="http://images.habbo.com/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/572/web-gallery/static/js/quickregister.js" type="text/javascript"></script>
<script src="http://www.html.it/guide/esempi/jquery/esempi/jquery-1.3.2.js" type="text/javascript"></script>
<style type="text/css">
.avanti_submit {
background: url(web-gallery/v2/images/avanti_submit.png);
border: none;
width: 132px;
height: 50px;
cursor: pointer;
}
.avanti_submit:hover {
background: url(web-gallery/v2/images/avanti_submit_hover.png);
}
.fatto_submit {
background: url(web-gallery/v2/images/fatto_submit.png);
border: none;
width: 90px;
height: 50px;
cursor: pointer;
}
.fatto_submit:hover {
background: url(web-gallery/v2/images/fatto_submit_hover.png);
}
</style>
<script type="text/javascript">
document.habboLoggedIn = false;
var habboName = null;
var habboReqPath = "";
var habboStaticFilePath = "./web-gallery";
var habboImagerUrl = "/habbo-imaging/";
var habboPartner = "";
window.name = "habboMain";
</script>
<!--[if lt IE 8]>
<link rel="stylesheet" href="./web-gallery/v2/styles/ie.css" type="text/css" />
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" href="./web-gallery/v2/styles/ie6.css" type="text/css" />
<script src="./web-gallery/static/js/pngfix.js" type="text/javascript"></script>
<script type="text/javascript">
try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}
</script>
<style type="text/css">
body { behavior: url(./web-gallery/csshover.htc); }
</style>
<![endif]-->
<meta name="build" content="9.0.47 - Login Template - HoloCMS" />
</head>
<body id="client" class="background-agegate">
<div id="overlay"></div>
<p class="phishing-warning">Questa schermata serve a proteggere i tuoi dati di accesso dai tentativi di furto. Assicurati che l'indirizzo della pagina web cominci con [url]http://[/url]<?php echo $config['ip']; ?>/ e chiudi la finestra se vedi indirizzi diversi!</p>
<?php
if(!is_numeric($step)) { $step = 1; }
$step = (htmlspecialchars($_GET['step'])) ? $_GET['step'] : 1;
switch($step) {
case 1:
$error = false;
if(isset($_POST['submit-1'])) {
$giorno = $_POST['giorno'];
$mese = $_POST['mese'];
$anno = $_POST['anno'];
$genere = $_POST['genere'];
if(empty($giorno) || empty($mese) || empty($anno)) {
$error = true;
} else {
$data = $giorno.'-'.$mese.'-'.$anno;
$_SESSION['data'] = $data;
$_SESSION['genere'] = $genere;
header('Location: register.php?step=2');
}
}
?>
<div id="main-container">
<?php if($error === true) { ?>
<?php } else { echo '<div id="error-placeholder"></div>'; } ?>
<form action="register.php?step=1" name="step1" method="POST">
<div id="title">
Data di nascita e sesso
</div>
<input type="submit" name="submit-1" class="avanti_submit" value="" />
</div>
</div>
</form>
</div>
break;
}
?>
</body>
</html>
Quindi diciamo che i codici sono molto semplici, l' errore generato (solo 3 step, ne ho messa solo una, per spostarmi da una step all' altra uso header location):
Warning: Cannot modify header information - headers already sent by (output started at /home/mybeat.it/public_html/register/register.php:14) in /home/mybeat.it/public_html/register/register.php on line 113
Linea 113 è la linea dell' header location alla step2, la linea 14 è la prima inclusione css, ovvero:
codice:
<link rel="stylesheet" href="http://images.habbo.com/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/572/web-gallery/static/styles/common.css" type="text/css" />
Come è possibile che questo sia un output?