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? 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. 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? 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. 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. 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? 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. 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. 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 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. 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 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
Archived
This topic is now archived and is closed to further replies.