nealec Posted January 27, 2011 Share Posted January 27, 2011 Im trying to get a login/register script to work in my existing page design but im getting an error, i have no idea what im doing i know next to nothing about php, i just follow tutorials. Most of the error is hidden because the font is the same color as the background but is says: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/aretheyh/public_html/nealeweb.com/index.php:16) in /home/aretheyh/public_html/nealeweb.com/index.php on line 25 Heres the page link where the error occurs: http://www.nealeweb.com/index.php Please help, im useless! Link to comment https://forums.phpfreaks.com/topic/225881-interating-script-into-site-design-help/ Share on other sites More sharing options...
litebearer Posted January 27, 2011 Share Posted January 27, 2011 We need to see the code Link to comment https://forums.phpfreaks.com/topic/225881-interating-script-into-site-design-help/#findComment-1166148 Share on other sites More sharing options...
nealec Posted January 27, 2011 Author Share Posted January 27, 2011 Sorry here you go <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>New Page 6</title> </head> <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0"> <div align="center"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td> <img border="0" src="nealewebpreviews/Design3/headimg.jpg" width="566" height="138"></td> <td> <img border="0" src="nealewebpreviews/Design3/clockdemo.jpg" width="264" height="138" align="right"></td> </tr> </table> </div> <div align="center"> <table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#000000"> <tr> <td width="40"> </td> <td> <?php session_start(); require_once 'database.php'; if (isset($_SESSION['user'])){ ?> <form name="logout" method="post" action="logout.php"> <input type="submit" name="logout" id="logout" value="Logout"> </form> <br /><form name="news" method="post" action="news.php"> <input type="submit" name="news" id="news" value="News"> </form> <?php } elseif(isset($_SESSION['admin'])){ echo"Welcome ".$_SESSION['admin']; echo"<br><br>You are logged in as an Admin"; ?> <form name="logout" method="post" action="logout.php"> <input type="submit" name="logout" id="logout" value="Logout"> </form> <br /><form name="news" method="post" action="news.php"> <input type="submit" name="news" id="news" value="News"> </form> <?php }else{ ?> <form name="login_form" method="post" action="login.php"> <label> <input name="user" type="text" id="user"><font color="#FFFFFF"> Username</font></label><p> <label> <br /> <input name="pass" type="password" id="pass" size="20"><font color="#FFFFFF"> Password</font><br /> </label></p> <p> <input type="submit" name="login" id="login" value="Login"> </label> <input type="submit" name="register0" id="register" value="Register"> </p> </p> </form> <form name="Register" method="post" action="reg.php"> </form> </form> <?php } ?></td> <td width="551"> <img border="0" src="nealewebpreviews/Design3/midbarimgr.jpg" width="551" height="223" align="right"></td> </tr> </table> </div> <div align="center"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td background="nealewebpreviews/Design3/mbarbg.jpg" width="1283"> <img border="0" src="nealewebpreviews/Design3/mbar.jpg" width="900" height="45"></td> <td background="nealewebpreviews/Design3/mbarbg.jpg"> <img border="0" src="nealewebpreviews/Design3/Collapse.jpg" width="52" height="45"></td> </tr> </table> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/225881-interating-script-into-site-design-help/#findComment-1166152 Share on other sites More sharing options...
nealec Posted January 27, 2011 Author Share Posted January 27, 2011 I have gone through it loads of times myself to see if i made any obvious mistakes but none of it makes any sense to me to be honest. Link to comment https://forums.phpfreaks.com/topic/225881-interating-script-into-site-design-help/#findComment-1166159 Share on other sites More sharing options...
Pikachu2000 Posted January 27, 2011 Share Posted January 27, 2011 You cannot have any output before anything that needs to send headers. Link to comment https://forums.phpfreaks.com/topic/225881-interating-script-into-site-design-help/#findComment-1166160 Share on other sites More sharing options...
nealec Posted January 27, 2011 Author Share Posted January 27, 2011 Sorry to be stupid but i dont know what that means or what to do about it Link to comment https://forums.phpfreaks.com/topic/225881-interating-script-into-site-design-help/#findComment-1166162 Share on other sites More sharing options...
litebearer Posted January 27, 2011 Share Posted January 27, 2011 Didn't test or proof-read; however, compare your original to this... (MAYBE even print both on paper and compare side-by-side to see differences) <?php session_start(); require_once ('database.php'); /* Not realyy needed as you are not doing anything with the database in this script */ ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>New Page 6</title> </head> <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0"> <div align="center"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td><img border="0" src="nealewebpreviews/Design3/headimg.jpg" width="566" height="138"></td> <td><img border="0" src="nealewebpreviews/Design3/clockdemo.jpg" width="264" height="138" align="right"></td> </tr> </table> </div> <div align="center"> <table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#000000"> <tr> <td width="40"> </td> <td> <?php if (isset($_SESSION['user'])){ ?> <a href="logout.php?logout=1">Log out</a> <br /> <a href="news.hp?news=1">News</a> <?php }elseif(isset($_SESSION['admin'])){ echo"Welcome " . $_SESSION['admin'] . "<br><br>You are logged in as an Admin"; ?> <a href="logout.php?logout=1">Log out</a> <br /> <a href="news.hp?news=1">News</a> <?php }else{ ?> <form name="login_form" method="post" action="login.php"> <label><input name="user" type="text" id="user"><font color="#FFFFFF"> Username</font></label> <p> <label><br /> <input name="pass" type="password" id="pass" size="20"><font color="#FFFFFF"> Password</font><br /> </label> </p> <p> <label><input type="submit" name="login" id="login" value="Login"></label> <input type="submit" name="register0" id="register" value="Register"> </p> </p> </form> <form name="Register" method="post" action="reg.php"> </form> <?php } ?> </td> <td width="551"><img border="0" src="nealewebpreviews/Design3/midbarimgr.jpg" width="551" height="223" align="right"></td> </tr> </table> </div> <div align="center"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td background="nealewebpreviews/Design3/mbarbg.jpg" width="1283"> <img border="0" src="nealewebpreviews/Design3/mbar.jpg" width="900" height="45"> </td> <td background="nealewebpreviews/Design3/mbarbg.jpg"> <img border="0" src="nealewebpreviews/Design3/Collapse.jpg" width="52" height="45"> </td> </tr> </table> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/225881-interating-script-into-site-design-help/#findComment-1166206 Share on other sites More sharing options...
Pikachu2000 Posted January 27, 2011 Share Posted January 27, 2011 There's a sticky topic on this as well: HEADER ERRORS - READ HERE BEFORE POSTING THEM Link to comment https://forums.phpfreaks.com/topic/225881-interating-script-into-site-design-help/#findComment-1166207 Share on other sites More sharing options...
nealec Posted January 27, 2011 Author Share Posted January 27, 2011 Didn't test or proof-read; however, compare your original to this... (MAYBE even print both on paper and compare side-by-side to see differences) <?php session_start(); require_once ('database.php'); /* Not realyy needed as you are not doing anything with the database in this script */ ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>New Page 6</title> </head> <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0"> <div align="center"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td><img border="0" src="nealewebpreviews/Design3/headimg.jpg" width="566" height="138"></td> <td><img border="0" src="nealewebpreviews/Design3/clockdemo.jpg" width="264" height="138" align="right"></td> </tr> </table> </div> <div align="center"> <table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#000000"> <tr> <td width="40"> </td> <td> <?php if (isset($_SESSION['user'])){ ?> <a href="logout.php?logout=1">Log out</a> <br /> <a href="news.hp?news=1">News</a> <?php }elseif(isset($_SESSION['admin'])){ echo"Welcome " . $_SESSION['admin'] . "<br><br>You are logged in as an Admin"; ?> <a href="logout.php?logout=1">Log out</a> <br /> <a href="news.hp?news=1">News</a> <?php }else{ ?> <form name="login_form" method="post" action="login.php"> <label><input name="user" type="text" id="user"><font color="#FFFFFF"> Username</font></label> <p> <label><br /> <input name="pass" type="password" id="pass" size="20"><font color="#FFFFFF"> Password</font><br /> </label> </p> <p> <label><input type="submit" name="login" id="login" value="Login"></label> <input type="submit" name="register0" id="register" value="Register"> </p> </p> </form> <form name="Register" method="post" action="reg.php"> </form> <?php } ?> </td> <td width="551"><img border="0" src="nealewebpreviews/Design3/midbarimgr.jpg" width="551" height="223" align="right"></td> </tr> </table> </div> <div align="center"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td background="nealewebpreviews/Design3/mbarbg.jpg" width="1283"> <img border="0" src="nealewebpreviews/Design3/mbar.jpg" width="900" height="45"> </td> <td background="nealewebpreviews/Design3/mbarbg.jpg"> <img border="0" src="nealewebpreviews/Design3/Collapse.jpg" width="52" height="45"> </td> </tr> </table> </div> </body> </html> Ok thanks thats got rid of the error msg but for some reason the login and register buttons are no longer taking me to the right pages Try it: http://www.nealeweb.com/index.php Link to comment https://forums.phpfreaks.com/topic/225881-interating-script-into-site-design-help/#findComment-1166225 Share on other sites More sharing options...
litebearer Posted January 27, 2011 Share Posted January 27, 2011 That's because (like I said about me not proofing - GRIN), you probably cut and pasted my code; AND LIKE ME did not see that I forgot the 'p' in the extensions ie .hp should be .php Link to comment https://forums.phpfreaks.com/topic/225881-interating-script-into-site-design-help/#findComment-1166286 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.