FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » buffering to allow headers in code?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: buffering to allow headers in code? [message #170173 is a reply to message #170169] Thu, 14 October 2010 20:51 Go to previous messageGo to previous message
Hamish Campbell is currently offline  Hamish Campbell
Messages: 15
Registered: September 2010
Karma:
Junior Member
On Oct 15, 5:32 am, MikeB <mpbr...@gmail.com> wrote:
> Since I'm trying to display the name of the logged in user on the left
> pane, that code is included before I run the code in the "main" cell,
> hence my timing problem

This is what was meant by "restructuring your code". You should really
perform any state operations (like 'login user x', 'delete page y',
etc) before you start building any output. Obviously, since you're
just starting out, it's not helpful to talk about MVC patterns (worth
a Google and some questions to your instructor, just to get your
money's worth :P), but try to think of the actual output as the final
step in the process. I.e., PHP gets the request, does all the
checking, redirection, database stuff, etc - before a single line of
output is sent to the buffer/browser.

in the meantime, sending a header redirect will work - just don't
forget to die() or exit() after the header call to stop further
(unnecessary) processing. It is a classic security blunder to assume
that code execution stops after the header is sent purely because the
browser goes on it's merry way.

Hope this helps,

Hamish
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Mesothelioma
Next Topic: Good code or bad code?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 22:19:46 GMT 2024

Total time taken to generate the page: 0.04770 seconds