I have a log in processing page that reads a function from a pinc file. The function is used to make sure that the log in info being provided is in my txt file. If there is a match - I want it to set some cookies and return true. The login page using this function will then confirm that we have the information and direct the person to a welcome page. The problem is I keep getting the following error:
Warning: Cannot modify header information - headers already sent by (output started at /staff/seebetra/homepage/ciss225/libraryTEST.pinc:29) in /staff/seebetra/homepage/ciss225/libraryTEST.pinc on line 22
I don't see where I am doing any outputting to the browser before the cookies are set.
Here is the page with the formula:
<?php
session_start();
function getLogin($username, $pass)
{
$username = trim($POST['email_address']);
$pass = trim($POST['password']);
$file = "/staff/seebetra/homepage/ciss225/registered_users.txt";
$data = file_get_contents($file);
$lines = explode("\n", $data);
foreach($lines as $line)
{
list($email_address, $password, $first_name, $last_name) = explode(":", trim($line));
if($username == $email_address && $pass == $password)
{
$SESSION['userName'] = $username;
$SESSION['fName'] = $first_name;
$_SESSION['lName'] = $last_name;
setcookie ("ok", $username);
return TRUE;
}
}
}
?>
Here is the page using the function:
<?php
include('/staff/seebetra/homepage/ciss225/libraryTEST.pinc');
if(!isset($_POST['submit']))
{
if (getLogin($username, $password) == TRUE);
{
$logged_in='Y';
echo "Thank You for Logging in";
echo "<html>
<head>
<meta http-equiv='Refresh' Content='8; url=welcome.php'>
<title>Thank You for logging in, You are now being redirected!!!!</title>
</head>
<body>
<a href='welcome.php'>Click Here</a> to go to Welcome Page";
}
}
?>
Any suggestions??