[PHP] Header() or Meta refresh to redirect?

C++, C#, Java, PHP, ect...
Post Reply
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

[PHP] Header() or Meta refresh to redirect?

Post by vitinho444 »

Hey guys, in the revamping of my engine, OLDTIMES ENGINE, i have situations that i need to redirect players to other pages.

In the first engine, i used meta refresh, <meta type=refresh> or something i dont remember, and now im using header("Location page.php");

What's the best, differences and ups and downs?
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
User avatar
Chris
Posts: 1580
Joined: Wed Sep 30, 2009 7:22 pm

Re: [PHP] Header() or Meta refresh to redirect?

Post by Chris »

The meta tag is executed by the browser once the HTML has been parsed and rendered. The header redirect is part of the HTTP network response headers and redirects at the networking level. All in all sending the redirect in the network response is the better option as the browser won't need to render the HTML before it will redirect, it also means people can't tamper the response data to not redirect. I was always advised to use the meta tag in the past, but I to this day still cannot figure out why. It might be something to do with the HTTP standards back in the day. A HTTP 303 redirect header as the response is the most convenient way in my opinion.

http://en.wikipedia.org/wiki/List_of_HTTP_status_codes

Conclusion:

Code: Select all

header('Location: whereEver.php'); 
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: [PHP] Header() or Meta refresh to redirect?

Post by vitinho444 »

Nice, im using the right one then :)
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: [PHP] Header() or Meta refresh to redirect?

Post by hallsofvallhalla »

Chris is back!
Post Reply

Return to “Coding”