bri4n Posted December 5, 2007 Share Posted December 5, 2007 Hi ya! I was wondering if someone can help me resolcve this simple problem. I get the following errors when trying to proces a page on my website: Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at /var/www/vhosts/sendadollar.co.nz/httpdocs/admin/adminprocess.php:15) in /var/www/vhosts/sendadollar.co.nz/httpdocs/admin/adminprocess.php on line 33 Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /var/www/vhosts/sendadollar.co.nz/httpdocs/admin/adminprocess.php:15) in /var/www/vhosts/sendadollar.co.nz/httpdocs/admin/adminprocess.php on line 33 Here is the code for the pages involved: <?php /*Connect to database*/ include("../include/assorted.inc.php"); $connection=mysql_connect($host,$user,$password) or die("Could not connect to the server"); $db=mysql_select_db($database,$connection) or die("Could not connect to the database"); $login_name=$_POST['login']; $password=$_POST['password']; /*See if login from form exists, if so then allow user to perform tasks, else ask for login*/ $query="SELECT password FROM admin WHERE password ='$password'"; $result=mysql_query($query) or die ("Could not execute query"); $count=mysql_num_rows($result); if ($count==1){ session_register("login"); session_register("password"); header("location:login_success.php"); } else { header("location:adminlogin.php"); echo "Wrong Login name or Password"; } ?> and here is the code for the adminprocess page: <html> <head> <link rel="stylesheet" type="text/css" href="../css/base.css"/> <title>Send-a-Dollar!</title> </head> <body> <center> <image src="../images/logo.gif" width="380" height="90"> </center> <hr> <p> <div id="contents"> <?php /*Connect to database*/ include("../include/assorted.inc.php"); $connection=mysql_connect($host,$user,$password) or die("Could not connect to the server"); $db=mysql_select_db($database,$connection) or die("Could not connect to the database"); $login_name=$_POST['login']; $password=$_POST['password']; /*See if login from form exists, if so then allow user to perform tasks, else ask for login*/ $query="SELECT password FROM admin WHERE password ='$password'"; $result=mysql_query($query) or die ("Could not execute query"); $count=mysql_num_rows($result); if ($count==1){ session_register("login"); session_register("password"); header("location:login_success.php"); } else { echo "Wrong Login name or Password"; } ?> </div> </body> </html> I was wondering if someone could tell me what I have done wrong. I know that somehow it is recognising the output of the header information, thus screwing up the session! Thanks for any help TIA Brian Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 5, 2007 Share Posted December 5, 2007 read this post http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Quote Link to comment Share on other sites More sharing options...
xProteuSx Posted December 5, 2007 Share Posted December 5, 2007 You have to send the register session command at the VERY START of your file: <?php session_start(); ?> <!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> ... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.