PHP login script?



Can someone please tell me what is wrong with my php login script? The
following eror occures:

Warning: session_start(): Cannot send session cookie - headers already
sent by (output started at /home/phpcodin/public_html/logincheck.php:8)
in /home/phpcodin/public_html/logincheck.php on line 34

Warning: session_start(): Cannot send session cache limiter - headers
already sent (output started at
/home/phpcodin/public_html/logincheck.php:8) in
/home/phpcodin/public_html/logincheck.php on line 34

My coding is as follows, I have blocked out all my database login
script. Any help will be aprreciated.

<html>
<head>
<title>Login Results</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>

<body>
<?
$login=$_POST['login'];
$pass=$_POST['pass'];

$db="";
$user="";
$password="";
$database="";

mysql_connect($db,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM contacts WHERE id='$id'";
$result=mysql_query($query);
$num=mysql_numrows($result);

$i=0;
while ($i < $num) {

$id=mysql_result($result,$i,"id");
$logincheck=mysql_result($result,$i,"login");
$passcheck=mysql_result($result,$i,"pass");
$level=mysql_result($result,$i,"level");
}

if(($logincheck == "$login") || ($passcheck == "$pass") || ($level !==
"userq") || ($login !== "") || ($pass !== "")){
session_start();
session_register("id");
session_register("login");
session_register("pass");
session_register("level");
print("<meta http-equiv=\"refresh\" content=\"0;url=members.php\">");
}
else{
print("Sorry, one of the following occured:<br><br>");
print("The username $login does not exist.<br>");
print("The password you entered is not correct.<br>");
print("<br>Please try again.<br><br>");
include("login.htm");
}
mysql_close();
?>

</body>
</html>

.