I programmed a PHP login script for my website and everything works. However, I have one minor problem I can't figure out. In my website's main page code, I inserted this code:
Code:
<?
include("login/include/session.php");
if($session->logged_in){
echo "Welcome <b>$session->username</b>, you are logged in. "
."[<a href=\"login/userinfo.php?user=$session->username\">My Account</a>] "
."[<a href=\"login/useredit.php\">Edit Account</a>] ";
if($session->isAdmin()){
echo "[<a href=\"login/admin/admin.php\">Admin Center</a>] ";
}
echo "[<a href=\"http://cullmandrumline.org/forum\">Forum</a>] ";
echo "[<a href=\"http://cullmandrumline.org/media\">Media</a>] ";
echo "[<a href=\"login/process.php\">Logout</a>]";
}
else{
echo "Welcome, Guest. [<a href=\"http://cullmandrumline.org/login/main.php\">Click here to log in.</a>] Not registered? [<a href=\"http://cullmandrumline.org/login/register.php\">Click here to register.</a>] <br><br>";
}
?>
I used this code to create a line at the top of the page to tell the user if they are logged in or not, and if they are or are not, displays the appropriate information. This works, but it always displays an error.
Here's the output:
Code:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/tyler/domains/cullmandrumline.org/public_html/main.php:9) in /home/tyler/domains/cullmandrumline.org/public_html/login/include/session.php on line 46
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/tyler/domains/cullmandrumline.org/public_html/main.php:9) in /home/tyler/domains/cullmandrumline.org/public_html/login/include/session.php on line 46
Welcome, Guest. [Click here to log in.] Not registered? [Click here to register.]
I've tried several things to resolve this, and I can't figure it out.
Can anyone help me?
Thanks,
Tyler