SamohtVII Posted April 25, 2013 Share Posted April 25, 2013 Hi all, I have a problem when i try and use my login area. It works fine on my local machine but when i upload it to my website i get this error: Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/pol77704/public_html/HoN/index.php:9) in /home/pol77704/public_html/HoN/index.php on line 13Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/pol77704/public_html/HoN/index.php:9) in /home/pol77704/public_html/HoN/index.php on line 13 here are the first 20 or so lines of index.php. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>HoN</title><link href="styles.css" rel="stylesheet" type="text/css" /> <link rel="shortcut icon" href="images/favicon.ico" /></head> <div id="container"> <div id="topBar"> <div id="login"> <?php session_start(); if($_SESSION['username']) { ?> <div id="welcome"> <?php echo "Welcome, ".$_SESSION['username']."!"; ?> <a href="logout.php">logout</a> </div> <?php } else { ?> <form method="post" action="login.php" id="login"> <input id="username" type="text" name="username" placeholder="username"> <input id="password" type="password" name="password" placeholder="password"> <input type="submit" value="Log in" class="submitButton"> </form> <form method="post" action="register.php" id="register"> <input type="submit" value="Register" class="submitButton"> </form> <?php } ?> </div> anyway I have no idea whats the problem as i am quite new to this. Let me know if you need more info.Thanks Link to comment Share on other sites More sharing options...
Ingolme Posted April 25, 2013 Share Posted April 25, 2013 session_start() has to be called before any content is printed out. Link to comment Share on other sites More sharing options...
SamohtVII Posted April 25, 2013 Author Share Posted April 25, 2013 (edited) Ah ok so at the top of the page. Works fine now thanks. Edited April 25, 2013 by SamohtVII Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now