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

Redirecting a site visitor based an a certain condition

ifedi
P: 60
What's the neatest way to redirect a site visitor to another page using php, based on one or more conditions? I've already used header('Loacation: another.php') in many of my scripts, but I find that there are problems sometimes.
I tried http_redirect(), but it seems I needed to put a number of things together to let my 'localhost' be able to word with it.
Any help'll be appreciated!
Feb 12 '08 #1
Share this Question
Share on Google+
3 Replies


Markus
Expert 5K+
P: 6,050
As far as i know header("Location: ... is the best way to deal with redirecting..
Feb 12 '08 #2

ronverdonk
Expert 2.5K+
P: 4,258
What's the neatest way to redirect a site visitor to another page using php, based on one or more conditions? I've already used header('Loacation: another.php') in many of my scripts, but I find that there are problems sometimes.
I tried http_redirect(), but it seems I needed to put a number of things together to let my 'localhost' be able to word with it.
Any help'll be appreciated!
I agree with markusn00b. When you say you are (sometimes) having problems with header(..), you should solve that problem (probably "Cannot modify headers ...etc.... " msg) and then use the header() command to redirect.

Ronald
Feb 12 '08 #3

ifedi
P: 60
I agree with markusn00b. When you say you are (sometimes) having problems with header(..), you should solve that problem (probably "Cannot modify headers ...etc.... " msg) and then use the header() command to redirect.

Ronald
Thanks guys for your comments. Don't really think it was a "Cannot modify headers ...etc.... " msg (which has to do with placing any browser output before the headers() is called), though I can't now pull out the exact situation where I had problems (limitations) with header().
At any rate, what's http_redirect() about, what has it got over headers() and how can I build its support into php?
As always, thanks.
Ifedi.
Feb 13 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.