session fejl - hjælp!!
hver gang jeg bruger session_start(), får jeg denne fejl:Warning: session_start(): Cannot send session cookie - headers already sent by (output started at C:\Programmer\Apache Group\Apache2\htdocs\www\loginsessions\members.php:2) in c:\php\phpinclude\accesscontrol.php on line 2
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:\Programmer\Apache Group\Apache2\htdocs\www\loginsessions\members.php:2) in c:\php\phpinclude\accesscontrol.php on line 2
Notice: Undefined index: uid in c:\php\phpinclude\accesscontrol.php on line 7
Notice: Undefined index: pwd in c:\php\phpinclude\accesscontrol.php on line 8
Nogen der ved hvad det betyder?
Her er mit script:
<?php
session_start();
include_once 'fejl.php';
include_once 'db_conn.php';
$uid = isset($_POST['uid']) ? $_POST['uid'] : $_SESSION['uid'];
$pwd = isset($_POST['pwd']) ? $_POST['pwd'] : $_SESSION['pwd'];
if(!isset($uid)){
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Log ind...</title>
</head>
<body>
<br>
<a href="logud.php">Log ud</a><br>
<h4>Du skal logge ind for at fortsætte...</h4>
Opret dig som bruger <a href="ny_bruger.htm">her</a>...<br />
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
brugernavn:<br>
<input type="text" name="uid" /><br>
password:<br>
<input type="password" name="pwd" /><br>
<input type="submit" name="login" value="Login" />
</form>
</body>
</html>
<?php
exit;
}
$_SESSION['uid'] = $uid;
$_SESSION['pwd'] = $pwd;
dbConnect("kyl");
$sql = "SELECT * FROM brugere WHERE brugernavn ='$uid' AND password = '$pwd'";
$result = mysql_query($sql);
if(!$result){
error('accesscontrol - databasefejl ved tjek af login...');
}
if(mysql_num_rows($result) == 0){
unset($_SESSION['uid']);
unset($_SESSION['pwd']);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Adgang nægtet!!</title>
</head>
<body>
<h4>Adgang nægtet!!</h4>
Dit brugernavn eller password er forkert, eller også er du ikke registreret<br>
Prøv at logge ind igen - <a href="<?=$_SERVER['PHP_SELF']?>">klik her</a>.<br>
Eller registrer dig som bruger - <a href="opret.php">klik her</a>.<br>
</body>
</html>
<?php
exit;
}
$navn = mysql_result($result,0,'brugernavn');
?>