phpSensei Posted August 23, 2007 Share Posted August 23, 2007 whats the difference between HEADER and META... I think its the fact that it doesnt have to come before the HEAD tags... So why don't people use it? Security issues? Im concerned. Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/ Share on other sites More sharing options...
nathanmaxsonadil Posted August 23, 2007 Share Posted August 23, 2007 it's obvious the header makes it so you hardly know that you're in the page and the meta does not there's probably more things but that is just what came to the top of my head Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-332449 Share on other sites More sharing options...
tibberous Posted August 23, 2007 Share Posted August 23, 2007 Meta refresh is slower and doesn't work as well. It screws up the back button too. Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-332450 Share on other sites More sharing options...
phpSensei Posted August 23, 2007 Author Share Posted August 23, 2007 Yes it does, It works fine without any stoppage time. And even if it wasnt as quick, it wouldnt be anything like refresh after 10 seconds. Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-332452 Share on other sites More sharing options...
phpSensei Posted August 24, 2007 Author Share Posted August 24, 2007 I just used it on a massive long script. And the redirect is as quick as header, except you see like a blink or something. It only lasts for like .0000000000000001 sec. Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-332459 Share on other sites More sharing options...
nathanmaxsonadil Posted August 24, 2007 Share Posted August 24, 2007 you must have a fast browser&computer Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-332461 Share on other sites More sharing options...
nathanmaxsonadil Posted August 24, 2007 Share Posted August 24, 2007 header sends a raw HTTP header so even before the page is loaded it redirects it also how did you find out that meta refresh took only .0000000000000001 sec. ? Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-332464 Share on other sites More sharing options...
Fadion Posted August 24, 2007 Share Posted August 24, 2007 From wikipedia about meta refresh: This is considered by the W3C to be a poor method of redirection, since it does not communicate any information about either the original or new resource, to the browser (or search engine). The W3C's Web Content Accessibility Guidelines (7.4) discourage the creation of auto-refreshing pages, since most web browsers do not allow the user to disable or control the refresh rate. Usually ive used meta refresh in my scripts, so i dont care about "headers already sent". Its a bad method or not, it gives me the result i want. Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-332467 Share on other sites More sharing options...
akitchin Posted August 24, 2007 Share Posted August 24, 2007 i'd say the most useful feature of a meta refresh is that it can be delayed. for example if you've let someone edit a profile, you can issue a success message that says "Profile successfully edited. You will be returned to your profile page shortly." and they will see the new page several seconds later. often times if you header() immediately to the following page, users will be left wondering whether their edit was successful or not. Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-332470 Share on other sites More sharing options...
phpSensei Posted August 24, 2007 Author Share Posted August 24, 2007 Alot of positivity for the META refreshing method, and header is mostly useless to me. Its always before the <HEAD> tags, which often I put my php scripts between, and the header is always sent by the ouput... Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-332550 Share on other sites More sharing options...
dbo Posted August 24, 2007 Share Posted August 24, 2007 In some ways meta refresh is like a javascript redirect. Users have the ability to disable this as a preference. Header redirects are handled on the server... users can't disable the transfer. As others have mentioned there is a use for some of the meta/javascript methods in that you can delay and send other output before deciding to do the redirect.... can't do this with header. Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-332556 Share on other sites More sharing options...
MadTechie Posted August 24, 2007 Share Posted August 24, 2007 both are good in their own way, just choose the right tool for the right job. Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-332565 Share on other sites More sharing options...
Jessica Posted August 24, 2007 Share Posted August 24, 2007 "often times if you header() immediately to the following page, users will be left wondering whether their edit was successful or not." That's why you display a success or failure message on the next page. Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-332615 Share on other sites More sharing options...
phpSensei Posted August 24, 2007 Author Share Posted August 24, 2007 EXACTLY, like someone else said up there, and when I use META, I leave a note like Success.... and the refresh shows the note long enough to take a glance. Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-332620 Share on other sites More sharing options...
dbo Posted August 24, 2007 Share Posted August 24, 2007 I dont think that's what jesirose meant. As MadTechie said, the right tool for the right job. You just need to be aware of the limitations and when meta/javascript will work and when they won't if you're counting on it being enabled for your site to function and someone doesn't you're going to rub your users the wrong way. If using meta/javascript id suggest also adding a link that says... if you aren't automatically redirected click here type of thing. Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-332623 Share on other sites More sharing options...
phpSensei Posted August 24, 2007 Author Share Posted August 24, 2007 sorry, i was following up on someone elses post. But Madtechie is right.... Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-332626 Share on other sites More sharing options...
dbo Posted August 24, 2007 Share Posted August 24, 2007 Damn that MadTechie! Just kidding, I enjoy his posts and always check them out Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-332634 Share on other sites More sharing options...
phpSensei Posted August 24, 2007 Author Share Posted August 24, 2007 lol,.....Stalker. Kidding. Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-332636 Share on other sites More sharing options...
akitchin Posted August 24, 2007 Share Posted August 24, 2007 "often times if you header() immediately to the following page, users will be left wondering whether their edit was successful or not." That's why you display a success or failure message on the next page. not if you don't want the hassle of sending yet another (relatively useless) request along with the header() redirection in order to flag that a success or error message should be shown. even though it's not exactly tough to do so, i just find it handier to echo the message where i've accepted and processed the request. but you're right, that's always an option. i personally don't see the harm in using a META refresh as long as you offer the user a link to where it's going anyway (be it to avoid a delay or whatever). Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-333035 Share on other sites More sharing options...
drewbee Posted August 24, 2007 Share Posted August 24, 2007 I personally can't stand the meta refresh. It generates a little to much overhead for a redirect (ie loading a page, refreshing, then loading another page). It can also be disabled. I prefer using headers as this is done and used before any output is sent to the browser. Yes it will throw an error if output is already sent. This is how headers are, it will throw an error if output is sent and you try and set any other data ie user agent, http-status. This is not just the redirect, but all headers in general. Also, bots can pick up on these redirects and know the information from where it came from as well as where it is going. If you have problems using redirect's in the right place, try coding for the better. For instance, after every single POST and processing takes place on my pages, I issue a header redirect. That way on the next page when the person hits refresh, it doesn't repost the data. When the user hits the back button, they are returned to the original form, rather then to the POSTED TO page. If you need help with these things, I highly recomend looking into output buffering. Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-333097 Share on other sites More sharing options...
drewbee Posted August 24, 2007 Share Posted August 24, 2007 I do agree with you though akitchin. If a meta refresh is to be used, always make sure their is a link pointing to the same place the refresh is going to. Nothing gurentee's that refresh will take them forward. Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-333098 Share on other sites More sharing options...
xyn Posted August 24, 2007 Share Posted August 24, 2007 though you can make header() pause too. aka. echo("chnages saved. you will be redirected..."); sleep(3); // pause for 3 seconds header("location: url"); Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-333106 Share on other sites More sharing options...
drewbee Posted August 24, 2007 Share Posted August 24, 2007 xyn, I have never done this. Wont this just display a blank screen for three seconds then redirect? Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-333110 Share on other sites More sharing options...
xyn Posted August 24, 2007 Share Posted August 24, 2007 no. because you echo something. the slee() will only pause the page for x seconds... http://php.net/sleep Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-333111 Share on other sites More sharing options...
MadTechie Posted August 24, 2007 Share Posted August 24, 2007 though you can make header() pause too. aka. echo("chnages saved. you will be redirected..."); sleep(3); // pause for 3 seconds header("location: url"); Nope thats will fail.. nothing can be sent to the screen before a header Quote Link to comment https://forums.phpfreaks.com/topic/66419-why-header-why-not-meta-refresh/#findComment-333113 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.