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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lister

    #1

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

    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('locatio n') 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.

    Cheers,
    Lister

  • Toby A Inkster

    #2
    Re: Changing pages: header('locatio n') or PHP require()?

    lister wrote:
    Currently I:
    1) Process any user submitted data in the current page
    2) Send a header('locatio n') redirect to the browser, which then
    requests the new page.
    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

    Comment

    Working...