By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,510 Members | 1,821 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,510 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.

Cheers,
Lister

May 30 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
lister wrote:
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.
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
http://tobyinkster.co.uk/blog/2007/0...tive-surnames/
May 30 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.