dadamssg Posted June 7, 2009 Share Posted June 7, 2009 i've seen this done on several sites. After, you complete a form or do somehing it takes to you to a page that temporarily displays a message and then redirects you to another page. How do you do this? after submitting the information from a form i want to display a message like "You're information is in review" or a "Please check your email for a confirmation link"...something like that and then after a certain amount of seconds, redirect to the homepage. any help would be great! Quote Link to comment https://forums.phpfreaks.com/topic/161233-display-message-then-redirect/ Share on other sites More sharing options...
jxrd Posted June 7, 2009 Share Posted June 7, 2009 You can use javascript or meta refresh. Quote Link to comment https://forums.phpfreaks.com/topic/161233-display-message-then-redirect/#findComment-850790 Share on other sites More sharing options...
Grayda Posted June 9, 2009 Share Posted June 9, 2009 There are three ways to achieve what you're after: Number one (anywhere in your script, preferably at the bottom so the page has time to load): <script language='javascript'>setTimeout('window.location="gohere.html"', 5000);</script> Pros: Quick and easy Doesn't break W3C standards Works well with back buttons Cons: Doesn't work in Javascript is turned off Number two (put this between your header tags): <meta http-equiv="refresh" content="5;url=gohere.html" /> Pros: Doesn't require Javascript Cons: Can prevent people from using the back button if redirected too quickly Discouraged by the W3C. Instead they encourage you to use 30x status code Number three (place BEFORE your PHP script outputs anything, since we're messing with headers): <?php Header( "HTTP/1.1 303 See Other" ); Header( "Location: gohere.html" ); ?> Pros:All browsers can understand this Encouraged by the W3C Cons: Should only be used for updating URLs. (eg. redirect from newsite.example.com to example.com when newsite goes live) Requires you use output buffering unless no content comes before the header change In essence, pick your poison. All three work well depending on your situation Quote Link to comment https://forums.phpfreaks.com/topic/161233-display-message-then-redirect/#findComment-852740 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.