PHP Header Refresh Issue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tom Post

    PHP Header Refresh Issue

    I am doing a simple php header refresh --
    header('refresh : 10; url=msgs.php');
    that just does a call back to my script every 10 seconds. Things work
    great when the page is first loaded up, but if the end user hits F5 or
    the refresh button, then the page stops refreshing indefinately. Any
    ideas how to make it so that the page perpetually refreshes regardless
    of what the end user presses?
  • Jasper Bryant-Greene

    #2
    Re: PHP Header Refresh Issue

    Tom Post wrote:
    [color=blue]
    > I am doing a simple php header refresh --
    > header('refresh : 10; url=msgs.php');
    > that just does a call back to my script every 10 seconds. Things work
    > great when the page is first loaded up, but if the end user hits F5 or
    > the refresh button, then the page stops refreshing indefinately. Any
    > ideas how to make it so that the page perpetually refreshes regardless
    > of what the end user presses?[/color]

    Put

    <meta http-equiv="refresh" content="10; url=msgs.php" />

    in the <head> section of the page, instead of using the PHP header() call.

    --
    Jasper Bryant-Greene
    Cabbage Promotions

    Comment

    • Michael Vilain

      #3
      Re: PHP Header Refresh Issue

      In article <92820a4b.04090 71249.6d76c344@ posting.google. com>,
      trpost@gtsquare d.com (Tom Post) wrote:
      [color=blue]
      > I am doing a simple php header refresh --
      > header('refresh : 10; url=msgs.php');
      > that just does a call back to my script every 10 seconds. Things work
      > great when the page is first loaded up, but if the end user hits F5 or
      > the refresh button, then the page stops refreshing indefinately. Any
      > ideas how to make it so that the page perpetually refreshes regardless
      > of what the end user presses?[/color]

      I think you're confusing the header information that the server sends to
      the browser with the <meta http-equiv="Refresh" > tag.

      The book I have on php doesn't describe the "refresh:" feature of the
      header() function. It describes redirections, expirations and cache
      stuff, authentication, and content-type, but no refresh. Nor does


      It could be you've chosen the wrong way to implement this. You can
      further check this by looking at the information the browser and server
      are sending by telneting into the server and pretending to be a browser.
      Some browsers like iCab have a log feature that keeps a transcript of
      activity. Try turning on that feature if you browser supports it.

      What happens if you code the header as html:

      echo "<HTML>\n",
      "<HEAD>\n",
      "<META HTTP-EQUIV='Refresh' CONTENT='10; URL=msgs.php'>\ n";

      Also be aware that some browsers don't like the refresh very well. I've
      had to remove it from my site because IE on the Mac didn't respond well
      to it.

      --
      DeeDee, don't press that button! DeeDee! NO! Dee...



      Comment

      • Michael Fesser

        #4
        Re: PHP Header Refresh Issue

        .oO(Tom Post)
        [color=blue]
        >I am doing a simple php header refresh --
        > header('refresh : 10; url=msgs.php');[/color]

        There's no such header in HTTP.

        Micha

        Comment

        • Janwillem Borleffs

          #5
          Re: PHP Header Refresh Issue

          Michael Fesser wrote:[color=blue]
          > .oO(Tom Post)
          >[color=green]
          >> I am doing a simple php header refresh --
          >> header('refresh : 10; url=msgs.php');[/color]
          >
          > There's no such header in HTTP.
          >[/color]

          Actually, there is. It's a response header on which the browser will act in
          the same manner as when a <META HTTP-EQUIV="Refresh" /> tag is included in
          an HTML document.

          See:




          JW



          Comment

          • Michael Fesser

            #6
            Re: PHP Header Refresh Issue

            .oO(Janwillem Borleffs)
            [color=blue]
            >Michael Fesser wrote:[color=green]
            >> .oO(Tom Post)
            >>[color=darkred]
            >>> I am doing a simple php header refresh --
            >>> header('refresh : 10; url=msgs.php');[/color]
            >>
            >> There's no such header in HTTP.
            >>[/color]
            >Actually, there is.[/color]

            Not in RFC 2616 (HTTP 1.1).
            [color=blue]
            >It's a response header on which the browser will act in
            >the same manner as when a <META HTTP-EQUIV="Refresh" /> tag is included in
            >an HTML document.
            >
            >See:
            >
            >http://tinyurl.com/6ozh3[/color]

            From that site (I hate these MSDN sites ... don't work in my Opera):

            REFRESH (46)
            Obsolete. Maintained for legacy application compatibility only.

            From <http://www.w3.org/Protocols/HTTP/Issues/http-wg.html>:

            REFRESH
            [...]
            Status: Not in 1.1, due to unexplored security implications.

            Micha

            Comment

            • Michael Vilain

              #7
              Re: PHP Header Refresh Issue

              In article <413e4d9b$0$416 93$1b2cd167@new s.euronet.nl>,
              "Janwillem Borleffs" <jw@jwscripts.c om> wrote:
              [color=blue]
              > Michael Fesser wrote:[color=green]
              > > .oO(Tom Post)
              > >[color=darkred]
              > >> I am doing a simple php header refresh --
              > >> header('refresh : 10; url=msgs.php');[/color]
              > >
              > > There's no such header in HTTP.
              > >[/color]
              >
              > Actually, there is. It's a response header on which the browser will act in
              > the same manner as when a <META HTTP-EQUIV="Refresh" /> tag is included in
              > an HTML document.
              >
              > See:
              >
              > http://tinyurl.com/6ozh3[/color]

              Interesting that this site (www.microsoft.com) says:

              REFRESH (46)
              Obsolete. Maintained for legacy application compatibility only.

              But http://vancouver-webpages.com/META/metatags.detail.html says this is
              a Netscape-specific extension. This is what I saw on my own site--IE
              didn't like this request and ignored it.

              --
              DeeDee, don't press that button! DeeDee! NO! Dee...



              Comment

              • Janwillem Borleffs

                #8
                Re: PHP Header Refresh Issue

                Michael Fesser wrote:[color=blue]
                > From that site (I hate these MSDN sites ... don't work in my Opera):
                >[/color]

                Switch over to Firefox then.
                [color=blue]
                > REFRESH (46)
                > Obsolete. Maintained for legacy application compatibility only.
                >
                > From <http://www.w3.org/Protocols/HTTP/Issues/http-wg.html>:
                >
                > REFRESH
                > [...]
                > Status: Not in 1.1, due to unexplored security implications.
                >[/color]

                The refresh header being obsolete and not implemented in HTTP/1.1 doesn't
                mean you cannot use it.

                It's the browser that determines whether to react on this header or not. The
                following code will redirect you to Google after 10 seconds in most
                browsers:

                <?php
                header("Refresh : 10; url=http://www.google.nl/");
                ?>


                JW



                Comment

                • R. Rajesh Jeba Anbiah

                  #9
                  Re: PHP Header Refresh Issue

                  Michael Fesser <netizen@gmx.ne t> wrote in message news:<00ksj0l86 c8sai4s0rfitevk dvir35lvn9@4ax. com>...
                  <snip>[color=blue][color=green]
                  > >http://tinyurl.com/6ozh3[/color]
                  >
                  > From that site (I hate these MSDN sites ... don't work in my Opera):[/color]

                  LOL!
                  [color=blue]
                  > REFRESH (46)
                  > Obsolete. Maintained for legacy application compatibility only.
                  >
                  > From <http://www.w3.org/Protocols/HTTP/Issues/http-wg.html>:
                  >
                  > REFRESH
                  > [...]
                  > Status: Not in 1.1, due to unexplored security implications.[/color]

                  IIRC, header("Locatio n:...") won't work in IIS and in that case the
                  only header work is header("Refresh ..."). So, it is not actually
                  obsolete.

                  FWIW:
                  <?php
                  function Redirect2URL($u rl)
                  {
                  if (!headers_sent( ))
                  {
                  header('Locatio n: '.$url);
                  //if IIS, then send Refresh header too (as a safe)...
                  if (stristr($_SERV ER['SERVER_SIGNATU RE'], 'IIS'))
                  header('Refresh : 0;url='.$url);
                  }
                  else
                  {
                  echo '<p>Please click this <a href="'.$url.'" >link</a> to
                  continue...</p>'."\n";
                  echo '<META HTTP-EQUIV="refresh" CONTENT="0; URL='.$url.'">' ."\n";
                  }
                  }
                  ?>

                  --
                  | Just another PHP saint |
                  Email: rrjanbiah-at-Y!com

                  Comment

                  • Tom Post

                    #10
                    Re: PHP Header Refresh Issue

                    trpost@gtsquare d.com (Tom Post) wrote in message news:<92820a4b. 0409071249.6d76 c344@posting.go ogle.com>...[color=blue]
                    > I am doing a simple php header refresh --
                    > header('refresh : 10; url=msgs.php');
                    > that just does a call back to my script every 10 seconds. Things work
                    > great when the page is first loaded up, but if the end user hits F5 or
                    > the refresh button, then the page stops refreshing indefinately. Any
                    > ideas how to make it so that the page perpetually refreshes regardless
                    > of what the end user presses?[/color]

                    I tried using:
                    <meta http-equiv="refresh" content="10; url=msgs.php" />

                    But it behaves exactly the same as using the php header fxn. If I hit
                    the IE refresh button, the refreshing no longer continues.

                    Comment

                    • Michael Vilain

                      #11
                      Re: PHP Header Refresh Issue

                      In article <92820a4b.04090 81039.644520d@p osting.google.c om>,
                      trpost@gtsquare d.com (Tom Post) wrote:
                      [color=blue]
                      > trpost@gtsquare d.com (Tom Post) wrote in message
                      > news:<92820a4b. 0409071249.6d76 c344@posting.go ogle.com>...[color=green]
                      > > I am doing a simple php header refresh --
                      > > header('refresh : 10; url=msgs.php');
                      > > that just does a call back to my script every 10 seconds. Things work
                      > > great when the page is first loaded up, but if the end user hits F5 or
                      > > the refresh button, then the page stops refreshing indefinately. Any
                      > > ideas how to make it so that the page perpetually refreshes regardless
                      > > of what the end user presses?[/color]
                      >
                      > I tried using:
                      > <meta http-equiv="refresh" content="10; url=msgs.php" />
                      >
                      > But it behaves exactly the same as using the php header fxn. If I hit
                      > the IE refresh button, the refreshing no longer continues.[/color]

                      I said in my post that IE doesn't support the Refresh header. Try using
                      a different browser. Refresh is a Netscape-specific part of HTTP/1.0
                      and was removed from HTTP/1.1.

                      Rethink your use of this 'feature'. It won't work on every browser and
                      especially on IE.

                      --
                      DeeDee, don't press that button! DeeDee! NO! Dee...



                      Comment

                      • John Dunlop

                        #12
                        Re: PHP Header Refresh Issue

                        Michael Vilain wrote:
                        [color=blue]
                        > I said in my post that IE doesn't support the Refresh header.[/color]

                        Mine does, but it's not on a Mac.


                        [color=blue]
                        > Try using a different browser.[/color]

                        Sound advice.
                        [color=blue]
                        > Refresh is a Netscape-specific part of HTTP/1.0 and was removed
                        > from HTTP/1.1.[/color]

                        Neither HTTP/1.0 nor 1.1 define a Refresh header. Although
                        it's not a violation of either to respond with a Refresh.
                        [color=blue]
                        > Rethink your use of this 'feature'.[/color]

                        Sound advice again.
                        [color=blue]
                        > It won't work on every browser and especially on IE.[/color]

                        HTTP/1.1 compliant implementations aren't required to treat
                        Refresh in any particular way. Decent browsers offer the
                        option of ignoring both Refresh headers and META refreshes.

                        --
                        Jock

                        Comment

                        Working...