Hi,

After someone logs in, I want to flash a message that says "Successfully logged in"
and then automatically redirect to another page via PHP.

How do I insert this pause?

right now I've got

header ("location: [url]http://www.cnn.com');[/url]

If I'm supposed to use the meta tag, I'm not sure how to use it b/c I'm using headers with php.

    Don't use header() with PHP.

    Or if you must redirect with header(), do it to a page that says your message and then redirects with a meta.

    Meta Refresh Howto

      Why bother with a meta redirect?

      <?php
      header('Refresh: 5; URL=http://cnn.com');
      ?>Please wait while you are redirected (in 5 seconds)...

        Well, I'll be damned! I always assumed that was a meta browser feature only. I did not know you could send that as an http header.

          Yep; the "http-equiv" part of a META element essentially means "Consider this tag as the equivalent of an HTTP header sent before the content."

            Aha, you learn something new everyday. I guess my "downfall" is probably the fact that I never "pause" pages before redirecting. Thanks for the enlightenment.

              a year later

              So...If I have Google Analytics code (javascript) that I want to execute prior to the redirect, what's the best way to do it? Since the JS is in the body, will a header redirect, even with a pause, allow the JS to be processed?

                ghalt wrote:

                will a header redirect, even with a pause, allow the JS to be processed?

                Yes, depending upon which type of header you use.

                If you want the HTML page to be displayed for a certain number of seconds before the browser should be redirected to a different URL, send a Refresh header instead of a Location header (which would tell the browser to redirect immediately without parsing the page).

                  Write a Reply...