di solito l'errore "header already sent..." viene visualizzato quando la pagina inizia con dei tag HTML e indica che gli header di intestazione della pagina sono già stati caricati dai tag e non dallo script php tramite session_start. in altre parole l'errore di solitoa ccade perchè scrivi così
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>LOGIN</title>
<body>
<?php
//ERRORE! SESSION_START deve stare all'inizio della pagina
session_start();
include 'connessione.php';
$utente=$_POST['utente'];
$pass=$_POST['pass'];
$query="SELECT * FROM Utenti WHERE Utente='$utente' AND Pass='$pass';";
$result= mysql_query($query,$conn);
$row= mysql_num_rows($result);
// ecc
?>
</body>
</html>
se invece scrivi nel modo seguente il problema dovrebbe risolversi
Codice PHP:
<?php
//CORRETTO! SESSION_START deve stare all'inizio della pagina
session_start();
include 'connessione.php';
$utente=$_POST['utente'];
$pass=$_POST['pass'];
$query="SELECT * FROM Utenti WHERE Utente='$utente' AND Pass='$pass';";
$result= mysql_query($query,$conn);
$row= mysql_num_rows($result);
// ecc
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>LOGIN</title>
<body>
</body>
</html>