Erro com sessões

wrproject

Power Member
Boas Pessoal eu tenho o seguinte código:

login.htm
Código:
<html>
<head>
</head>
<body>
<br>
<br>
<div align=center>
<h1>Login</h1>
</div>
<div valign="center" align=center>
<form action="loginin.php" method="post">
NICK:<br>
<input type="text" name="nick">
<br>
Password<br>
<input type="password" method="post">
<br><br>
<input type="submit" name="submit" value="submit">
</form>
</div>
</body>
</html>

e depois tenho esse para efectuar o login:

loginin.php

PHP:
<?php
include "conecta.php";
echo "<br><br>";
$nick=$_POST['nick'];
$password=$_POST['password'];
$sql=mysql_query("select * from utilizadores where nick='$user' and password='$password'");
if(mysql_num_rows($sql)>0){
echo "user existe";
session_start();
$_SESSION[user]=$user;
header("location:www.topicos_recentes.php");
}
else{echo "user nao existe";}
?>

o que se passa é o seguinte, ele não consegue criar as sessões e dame sempre o seguinte erro:

"
user existe
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/www/bitzero.freehostia.com/forum2/loginin.php:3) in /home/www/bitzero.freehostia.com/forum2/loginin.php on line 9

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/www/bitzero.freehostia.com/forum2/loginin.php:3) in /home/www/bitzero.freehostia.com/forum2/loginin.php on line 9

Warning: Cannot modify header information - headers already sent by (output started at /home/www/bitzero.freehostia.com/forum2/loginin.php:3) in /home/www/bitzero.freehostia.com/forum2/loginin.php on line 11"

é este o erro que me da, alguem podia ajudarme?
abracos.
 
Os http headers têm que ser as primeiras coisas
a serem enviadas para o cliente. Tens duas hipoteses para
solucionar o problema. Uma é meteres todas as headers
antes de qualquer output ou então usares output buffer, normalmente é o que faço para não me chatear.
Para mais informações sobre output buffering procura no php.net/manual por ob_start() .
 
Back
Topo