User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 426,416 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,362 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting

php header() redirect issues

Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: php header() redirect issues

  #4  
Dec 21st, 2007
Originally Posted by Designer_101 View Post
This is a really common problem that occurs when using php to redirect users. The header must be at the top of the page (first thing the browser reads).

Wrong. The header can be anywhere in the script. The only thing is, you shouldn't output anything before the header function(not even a html tag). header("location: http://whatever.com/thankyou.php"); is just as good as
echo("<script>location.href = 'http://whatever.com/thankyou.php';</script>");

P.S. header is comparatively faster since its a php function, where as in the other case, it should first 'echo' the redirect script.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
All times are GMT -4. The time now is 1:56 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC