Re: buffering to allow headers in code? [message #170165 is a reply to message #170163] |
Thu, 14 October 2010 13:46 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 10/14/2010 9:39 AM, MikeB wrote:
> I'm working through my class on PHP and I tried to put information from
> my sign-on process in the navbar. This didn't work well, since I had to
> reload the page to see it as the navbar was constructed earlier in the
> code than the signon process. (Hard to explain, as we are building a
> "dynamic" web page with lots of include files to fill in the main
> content portion of the page.)
>
> My instructor suggested that I do the reload of the page via php
>
> header("Location: index.php");
>
> after the sign-in. To do this, I have to turn on output buffering.
>
> I recall struggling to turn off output buffering since someone here
> recommended against it.
>
> Any thoughts on this? Is this just a "quick and dirty" bypass for my
> problem, accepted practice, a really bad idea, or customary practice?
>
> I think I can code around this with some effort by putting a switch
> statement in the header of the index.php, but that may be clumsy as
> parts of the same web page will then be processed in two different areas.
>
> What to do?
>
> Thanks for any advice.
Actually, I read that wrong - sorry.
If your code is constructed properly, the header command will be sent
before any output - and no problem. If you buffer your output then send
the header command, the output won't get to the screen, anyway. So
there's no point.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|