Jump to content

display message then redirect


dadamssg

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.