By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,840 Members | 2,338 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,840 IT Pros & Developers. It's quick & easy.

PHP Header Refresh Issue

P: n/a
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?
Jul 17 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
Tom Post wrote:
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?


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
Jul 17 '05 #2

P: n/a
In article <92**************************@posting.google.com >,
tr****@gtsquared.com (Tom Post) wrote:
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?


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
http://us4.php.net/manual/en/function.header.php

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...

Jul 17 '05 #3

P: n/a
.oO(Tom Post)
I am doing a simple php header refresh --
header('refresh: 10; url=msgs.php');


There's no such header in HTTP.

Micha
Jul 17 '05 #4

P: n/a
Michael Fesser wrote:
.oO(Tom Post)
I am doing a simple php header refresh --
header('refresh: 10; url=msgs.php');


There's no such header in HTTP.


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
JW

Jul 17 '05 #5

P: n/a
.oO(Janwillem Borleffs)
Michael Fesser wrote:
.oO(Tom Post)
I am doing a simple php header refresh --
header('refresh: 10; url=msgs.php');
There's no such header in HTTP.

Actually, there is.


Not in RFC 2616 (HTTP 1.1).
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


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
Jul 17 '05 #6

P: n/a
In article <41***********************@news.euronet.nl>,
"Janwillem Borleffs" <jw@jwscripts.com> wrote:
Michael Fesser wrote:
.oO(Tom Post)
I am doing a simple php header refresh --
header('refresh: 10; url=msgs.php');


There's no such header in HTTP.


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


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...

Jul 17 '05 #7

P: n/a
Michael Fesser wrote:
From that site (I hate these MSDN sites ... don't work in my Opera):

Switch over to Firefox then.
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.


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

Jul 17 '05 #8

P: n/a
Michael Fesser <ne*****@gmx.net> wrote in message news:<00********************************@4ax.com>. ..
<snip>
http://tinyurl.com/6ozh3
From that site (I hate these MSDN sites ... don't work in my Opera):


LOL!
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.


IIRC, header("Location:...") 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($url)
{
if (!headers_sent())
{
header('Location: '.$url);
//if IIS, then send Refresh header too (as a safe)...
if (stristr($_SERVER['SERVER_SIGNATURE'], '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
Jul 17 '05 #9

P: n/a
tr****@gtsquared.com (Tom Post) wrote in message news:<92**************************@posting.google. com>...
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?


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.
Jul 17 '05 #10

P: n/a
In article <92*************************@posting.google.com> ,
tr****@gtsquared.com (Tom Post) wrote:
tr****@gtsquared.com (Tom Post) wrote in message
news:<92**************************@posting.google. com>...
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?


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.


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...

Jul 17 '05 #11

P: n/a
Michael Vilain wrote:
I said in my post that IE doesn't support the Refresh header.
Mine does, but it's not on a Mac.

http://www.hixie.ch/tests/evil/mixed/refresh1.http.html
Try using a different browser.
Sound advice.
Refresh is a Netscape-specific part of HTTP/1.0 and was removed
from HTTP/1.1.
Neither HTTP/1.0 nor 1.1 define a Refresh header. Although
it's not a violation of either to respond with a Refresh.
Rethink your use of this 'feature'.
Sound advice again.
It won't work on every browser and especially on IE.


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
Jul 17 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.