President Obama Posted January 18, 2011 Share Posted January 18, 2011 I read somewhere that theres a better way to redirect a page then using header("") I googled it up a bit but didn't find anything. Anyone know of any? Quote Link to comment https://forums.phpfreaks.com/topic/224814-a-better-redirect-instead-of-header/ Share on other sites More sharing options...
bh Posted January 18, 2011 Share Posted January 18, 2011 Interesting question. In html with meta tag? <meta http-equiv="refresh" content="1;url=http://www.example.com"> But, i think "header" function (with status:302) its ok. Quote Link to comment https://forums.phpfreaks.com/topic/224814-a-better-redirect-instead-of-header/#findComment-1161232 Share on other sites More sharing options...
trq Posted January 18, 2011 Share Posted January 18, 2011 Define 'better'. header redirects, what exactly would you do to improve it? Quote Link to comment https://forums.phpfreaks.com/topic/224814-a-better-redirect-instead-of-header/#findComment-1161233 Share on other sites More sharing options...
President Obama Posted January 18, 2011 Author Share Posted January 18, 2011 I don’t recommend, for example, using header() to bounce your users around to different pages; there are better methods that reduce the number of page loads and give the user a more fluid experience. http://tinsology.net/2009/06/creating-a-secure-login-system-the-right-way/ Thats where I saw it. Quote Link to comment https://forums.phpfreaks.com/topic/224814-a-better-redirect-instead-of-header/#findComment-1161240 Share on other sites More sharing options...
trq Posted January 18, 2011 Share Posted January 18, 2011 I would assume from the quotes that the author may be implying the use of Ajax and avoiding redirects almost all together. Quote Link to comment https://forums.phpfreaks.com/topic/224814-a-better-redirect-instead-of-header/#findComment-1161243 Share on other sites More sharing options...
President Obama Posted January 18, 2011 Author Share Posted January 18, 2011 Is that really much of an advantage? Quote Link to comment https://forums.phpfreaks.com/topic/224814-a-better-redirect-instead-of-header/#findComment-1161246 Share on other sites More sharing options...
trq Posted January 18, 2011 Share Posted January 18, 2011 Is that really much of an advantage? Well, it would allow an entire registration or login process to happen without ever reloading the page. Quote Link to comment https://forums.phpfreaks.com/topic/224814-a-better-redirect-instead-of-header/#findComment-1161249 Share on other sites More sharing options...
Anti-Moronic Posted January 18, 2011 Share Posted January 18, 2011 ..and while doing things like this try to remember accessibility. Have a fallback in case people don't have javascript enabled. As a major benefit, consider a complex filter/sort page which lends itself to being filtered and sorted by nature (like an online store). Using ajax, this entire process can be contained in a single page view without any refresh. Adds to a very seamless user experience. I really think ajax will be used on almost every website in the future. Gives you that 'desktop application' feeling. Quote Link to comment https://forums.phpfreaks.com/topic/224814-a-better-redirect-instead-of-header/#findComment-1161325 Share on other sites More sharing options...
mikosiko Posted January 18, 2011 Share Posted January 18, 2011 I don’t recommend, for example, using header() to bounce your users around to different pages; there are better methods that reduce the number of page loads and give the user a more fluid experience. http://tinsology.net/2009/06/creating-a-secure-login-system-the-right-way/ Thats where I saw it. in the same article the author explain his point of view: In the example, when a user registers the script that processes the information is called register.php, while the script that contains the form is called register_form.php. If the user fails to input a certain field then they are bounced back to register_form.php. This is a waste of bandwidth and time. register.php and register_form.php should both be the same script. For example Quote Link to comment https://forums.phpfreaks.com/topic/224814-a-better-redirect-instead-of-header/#findComment-1161336 Share on other sites More sharing options...
President Obama Posted January 18, 2011 Author Share Posted January 18, 2011 I've been avoiding AJAX just seemed a little complicated. I might as well have another look into it. Quote Link to comment https://forums.phpfreaks.com/topic/224814-a-better-redirect-instead-of-header/#findComment-1161356 Share on other sites More sharing options...
kenrbnsn Posted January 18, 2011 Share Posted January 18, 2011 Using the jQuery framework makes AJAX much easier. Ken Quote Link to comment https://forums.phpfreaks.com/topic/224814-a-better-redirect-instead-of-header/#findComment-1161398 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.