Could anyone please help me.
I get this message when I try to call setcookie() or header():
Warning: Cannot modify header information - headers already sent by (output started at C:\Documents and Settings\Tomek\Moje dokumenty\WWW\PW\login.php:2) in C:\Documents and Settings\Tomek\Moje dokumenty\WWW\PW\login.php on line 37
The source goes like this:
//first line empty
<?php //line nr 2 at which,it is said, the output is starting
$nazwa = $_POST['nazwa'];
$haslo = $_POST['haslo'];
function pc_validate($user,$pass)
{
//definition of a pass validation function
}
if (!pc_validate($nazwa,$haslo))
{
echo "ERROR!";
exit;
}
else
{
dokument_id = $_GET['dokument_id'];
if ($dokument_id == "")//this doesn't happen because script doesn't exit
{
echo "Nie ustalono celu.";
exit;
}
$adres = "http://www.myaddress.pl/$dokument_id.php";
//two lines which causes the problem (nr 36 & 37)
setcookie('login',$nazwa.','.md5($nazwa.'secret word'));
header('Location: '.$adres);
}
?>
My configuration is localhost with Apache 2.0.47 on WinXP with PHP 4.3.3 as part of a server (not as CGI). All works perfectly well on a remote server with Unix.
Any ideas how to solve the problem and be able to send header information?
EDIT: added source