Fejlbesked omkring header
Hejsa,Har dette script der bruges til bruger-login:
<?
// login.php - performs validation
// authenticate using form variables
$status = authenticate($f_user, $f_pass);
// if user/pass combination is correct
if ($status == 1)
{
// initiate a session
session_start();
// register some session variables
session_register("SESSION");// including the username
session_register("SESSION_UNAME");
$SESSION_UNAME = $f_user;
// redirect to protected page
header("Location: /upload.php");
exit();
}
else
// user/pass check failed
{
// redirect to error page
header("Location: /error.php?e=$status");
exit();
}
// authenticate username/password against a database
// returns: 0 if username and password is incorrect
// 1 if username and password are correct
function authenticate($f_user, $f_pass)
{
// configuration variables
// normally these should be sourced from an external file
// for example: include("dbconfig.php");
// variables explicitly set here for illustrative purposes
$db_host = "xxx";
$db_user = "xxx";
$db_pass = "xxx";
$db_name = "xxx";
// check login and password
// connect and execute query
$connection = mysql_connect($db_host, $db_user, $db_pass) or die
("Unable to connect!");
$query = "SELECT id from users WHERE username = '$f_user' AND password = '$f_pass'";
mysql_select_db($db_name);
$result = mysql_query($query, $connection) or die ("Error in query: $query. " . mysql_error());
// if row exists -> user/pass combination is correct
if (mysql_num_rows($result) == 1){
return 1;
}
// user/pass combination is wrong
else{
return 0;
}
}
?>
Men hver gang jeg kører det får jeg flg. fejl:
Warning: Cannot modify header information - headers already sent by (output started at xxx\logintest.php:1) in xxx\logintest.php on line 22
Hjælp:-)
