Changing pages: header('location') or PHP require()?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi all,

Just wondering whether there was any standard way of serving up a new
page to the browser when the user has submitted the current page.

Currently I:
1) Process any user submitted data in the current page
2) Send a header('location') redirect to the browser, which then
requests the new page.

I was considering that is it probably more efficient PHP to serve up
the new page contents immediately, without requiring another HTTP
request from the browser and the subsequent PHP setup overhead. Also
this would prevent having to store stuff in the user session to
maintain state.  I was going to try this with require(), but
immediately hit problems in that my pages have functions called the
same thing, so PHP falls over. Upon thinking about it further I could
can also see possible problems with $_POST data containing stuff from
the old page that could screw up the new page, and possible wierdness
with the browser address bar still having the old page address.

Is there an accepted way of doing this? Or is just a case of weighing
up the pro's and cons.


Re: Changing pages: header('location') or PHP require()?

lister wrote:

Quoted text here. Click to load it

This is the best option as it discourages reloads. (e.g. browser F5 key.)

Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 95 days, 18:37.]

                           Non-Intuitive Surnames

Site Timeline