Re: [PHP-DB] Re: HTTP header information
You may try with this: // then here is all the html for that page Bye Basile Francesco "Philip Thompson" <[EMAIL PROTECTED]> ha scritto nel messaggio news:[EMAIL PROTECTED] > > On Jun 10, 2004, at 9:44 AM, Torsten Roehr wrote: > > > "Philip Thompson" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > >> Hi all. > >> > >> I am running a website to where a user needs to login to authenticate > >> themselves to perform certain tasks. So a user logs in, and I start a > >> session (in PHP, of course). Well, the catch is, I am doing this all > >> from one page, 'viewer.php', and I just tack on the specific view/page > >> that I want them to see, depending on the link selected on that page. > >> Meaning, they click on the 'submit problem' link and it goes to > >> 'viewer.php?type=submitproblem'. > >> > >> The problem comes whenever I load the view 'submitproblem' and I start > >> a session with session_start(), which carries over the variable to > >> tell > >> whether or not the user is logged in. If they have not logged in > >> whenever they click on 'submitproblem' then it will redirect them to > >> 'viewer.php?type=login'. So I log in, and then go to 'submitproblem'. > >> > >> This is where I get the error: "Warning: session_start(): Cannot send > >> session cookie - headers already sent". Essentially, I understand why > >> this is occurring, but is there an easy way to get around it without > >> creating a new page, such as 'submitproblem.php' instead of > >> 'viewer.php?type=submitproblem'??? > > > > Make sure that NO output is done before session_start() is called. Can > > you > > post some of your code? > > > > Regards, > > > > Torsten Roehr > > > > See, that's the case. Because I'm essentially just changing the content > within the page, it never leaves the page 'viewer.php' - it just > changes the content by tacking on '?type=login, submitproblem, etc'. > > But my code in the beginning of the file 'submitproblem.view' is: > > session_start(); > > if (!session_is_registered('_isLoggedIn')) { > header ("Location:viewer.php?type=login"); > } else { > // do the stuff to submit a problem if they have > // logged in and have pressed the "submit" button > // in the html > } > > ?> > > // then here is all the html for that page > > So, does that help any? > > ~Philip -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: HTTP header information
Another little nift thing ive learned to always do regarding headers, is to always - ALWAYS - after a location have an exit; Example : header("location: somewhere.php"); exit; Ive learned that sometimes someting odd happens to the server and PHP delivers notices and errors to the browser. Sometimes something in your code could go wrong leading to a header not working the way intended. Point is, having the exit atleast stops the user from getting alot of stuff which he didnt accually want on the screen. I remember one of my earlier login systems, and if the login wasnt valid the user was sendt to the login page, pretty old fashioned. Problem was I didnt have an exit behind, and the webserver got a hickup. There happened someting wrong with the /tmp folder on the server so PHP issued an error on all pages that there was errors with the sessions, meaning something was printed out before my validation of the login, and the user accually got the content he wasnt allowed to see, :) This is abit off topic, but you never know. Headers are headers, and small things are small things... Good luck. -- -- Kim Steinhaug -- There are 10 types of people when it comes to binary numbers: those who understand them, and those who don't. -- www.steinhaug.com - www.easywebshop.no - www.webkitpro.com -- "James Harrell" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >> Make sure that NO output is done before session_start() is called. Can > >> you post some of your code? > >> > > >See, that's the case. Because I'm essentially just changing the content > >within the page, it never leaves the page 'viewer.php' - it just > >changes the content by tacking on '?type=login, submitproblem, etc'. > > Look for an errant space or CR after your original closing PHP tag. Also > check the file CR/LF/EOF spec is the same as that of your server. For > example, if your server is unix and your dev machine in Win32, dos2unix > the file to make certain there are no extra characters after the closing > php tag. > > Any output- even a space or extra CR/LF will cause PHP to send the headers. > > James -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: HTTP header information
>> Make sure that NO output is done before session_start() is called. Can >> you post some of your code? >> >See, that's the case. Because I'm essentially just changing the content >within the page, it never leaves the page 'viewer.php' - it just >changes the content by tacking on '?type=login, submitproblem, etc'. Look for an errant space or CR after your original closing PHP tag. Also check the file CR/LF/EOF spec is the same as that of your server. For example, if your server is unix and your dev machine in Win32, dos2unix the file to make certain there are no extra characters after the closing php tag. Any output- even a space or extra CR/LF will cause PHP to send the headers. James -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: HTTP header information
"Philip Thompson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > On Jun 10, 2004, at 9:44 AM, Torsten Roehr wrote: > > > "Philip Thompson" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > >> Hi all. > >> > >> I am running a website to where a user needs to login to authenticate > >> themselves to perform certain tasks. So a user logs in, and I start a > >> session (in PHP, of course). Well, the catch is, I am doing this all > >> from one page, 'viewer.php', and I just tack on the specific view/page > >> that I want them to see, depending on the link selected on that page. > >> Meaning, they click on the 'submit problem' link and it goes to > >> 'viewer.php?type=submitproblem'. > >> > >> The problem comes whenever I load the view 'submitproblem' and I start > >> a session with session_start(), which carries over the variable to > >> tell > >> whether or not the user is logged in. If they have not logged in > >> whenever they click on 'submitproblem' then it will redirect them to > >> 'viewer.php?type=login'. So I log in, and then go to 'submitproblem'. > >> > >> This is where I get the error: "Warning: session_start(): Cannot send > >> session cookie - headers already sent". Essentially, I understand why > >> this is occurring, but is there an easy way to get around it without > >> creating a new page, such as 'submitproblem.php' instead of > >> 'viewer.php?type=submitproblem'??? > > > > Make sure that NO output is done before session_start() is called. Can > > you > > post some of your code? > > > > Regards, > > > > Torsten Roehr > > > > See, that's the case. Because I'm essentially just changing the content > within the page, it never leaves the page 'viewer.php' - it just > changes the content by tacking on '?type=login, submitproblem, etc'. > > But my code in the beginning of the file 'submitproblem.view' is: > > session_start(); > > if (!session_is_registered('_isLoggedIn')) { > header ("Location:viewer.php?type=login"); > } else { > // do the stuff to submit a problem if they have > // logged in and have pressed the "submit" button > // in the html > } > > ?> > > // then here is all the html for that page > > So, does that help any? Looks okay, but PHP complains when you are trying to set the cookie. Can you post some lines from where you're setting the cookie? Torsten -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: HTTP header information
On Jun 10, 2004, at 9:44 AM, Torsten Roehr wrote: "Philip Thompson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi all. I am running a website to where a user needs to login to authenticate themselves to perform certain tasks. So a user logs in, and I start a session (in PHP, of course). Well, the catch is, I am doing this all from one page, 'viewer.php', and I just tack on the specific view/page that I want them to see, depending on the link selected on that page. Meaning, they click on the 'submit problem' link and it goes to 'viewer.php?type=submitproblem'. The problem comes whenever I load the view 'submitproblem' and I start a session with session_start(), which carries over the variable to tell whether or not the user is logged in. If they have not logged in whenever they click on 'submitproblem' then it will redirect them to 'viewer.php?type=login'. So I log in, and then go to 'submitproblem'. This is where I get the error: "Warning: session_start(): Cannot send session cookie - headers already sent". Essentially, I understand why this is occurring, but is there an easy way to get around it without creating a new page, such as 'submitproblem.php' instead of 'viewer.php?type=submitproblem'??? Make sure that NO output is done before session_start() is called. Can you post some of your code? Regards, Torsten Roehr See, that's the case. Because I'm essentially just changing the content within the page, it never leaves the page 'viewer.php' - it just changes the content by tacking on '?type=login, submitproblem, etc'. But my code in the beginning of the file 'submitproblem.view' is: if (!session_is_registered('_isLoggedIn')) { header ("Location:viewer.php?type=login"); } else { // do the stuff to submit a problem if they have // logged in and have pressed the "submit" button // in the html } ?> // then here is all the html for that page So, does that help any? ~Philip -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: HTTP header information
"Philip Thompson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all. > > I am running a website to where a user needs to login to authenticate > themselves to perform certain tasks. So a user logs in, and I start a > session (in PHP, of course). Well, the catch is, I am doing this all > from one page, 'viewer.php', and I just tack on the specific view/page > that I want them to see, depending on the link selected on that page. > Meaning, they click on the 'submit problem' link and it goes to > 'viewer.php?type=submitproblem'. > > The problem comes whenever I load the view 'submitproblem' and I start > a session with session_start(), which carries over the variable to tell > whether or not the user is logged in. If they have not logged in > whenever they click on 'submitproblem' then it will redirect them to > 'viewer.php?type=login'. So I log in, and then go to 'submitproblem'. > > This is where I get the error: "Warning: session_start(): Cannot send > session cookie - headers already sent". Essentially, I understand why > this is occurring, but is there an easy way to get around it without > creating a new page, such as 'submitproblem.php' instead of > 'viewer.php?type=submitproblem'??? Make sure that NO output is done before session_start() is called. Can you post some of your code? Regards, Torsten Roehr -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php