Vedr: Fejlmelding ved start af Session
Hvorfor får jeg følgende fejl hver gang jeg prøver at starte en sessionWarning: session_start()[<a href='function.session-start'>function.session-start]</a>:Cannot send session cookie - headers already sent in C:\Inetpub\wwwroot\php\login.php
<?php
session_start(); //fejl her
if (isset($_POST['username']) && isset($_POST['password'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$connection = mysql_connect('localhost', 'root', '')
if(!connection)
{
die('Kunne ikke forbinde til databasen: '.mysql_error());
}
mysql_select_db('Forening', $connection);
$sql = "SELECT * FROM person WHERE Username='$username' "
." AND Password='".sha1($password)."'";
//." AND Password='$password'";
$result = mysql_query($sql, $connection);
//valid username sættes
if (mysql_affected_rows() > 0){
$_SESSION['valid_user'] = $username;
$redirect = 'location: HentPersonFraForeningstabel.php?RedirectFrom='.basename(__FILE__);
header($redirect);
}
mysql_close();
$_SESSION['sql'] = $sql;
}
//tjek for at se krypteringen af 1234 og sql-streng
//print sha1('1234');
//print $sql;
?>