Help - Search - Members - Calendar
Full Version: Headers
Weborum Webmaster Forum > Web Page Design > PHP
Joe
Is there a header command that just refreshes the current page rather than using an absolute URI?

Reason being, there is a script, that could be executed on any page, and whichever page it is should be refreshed rather than redirecting back to a specific page.

TIA
Waleed
might be a...stupidy answer but how about the META refresh tag? pinch.gif
Joe
Meta tags display in the head of the page ... I'm after a function which refreshes the current page after a script has been run so the meta refresh tag wouldn't work, thanks for the idea though.
Joe
Strangly enough Waleed, the meta refresh tag works a treat smile.gif Good thinking on that one. The script is working fine now.
Waleed
lol. just goes to show you, never underestimate a fool!
sjthomas
If you wanted to do it in PHP Joe you could use a header: location and set the target to $PHP_SELF and providing the server is set up right it'll work.
Joe
I was looking for a PHP solution, I didn't realise php_self would work. I'll give that a shot, thanks.
Joe
Si,

I've just tried it, but I think I'm doing it wrong. How would the syntax work?

CODE
header('Location: $_SERVER['PHP_SELF']');
Willy Duitt
CODE

header("Location: http://www.$SERVER_NAME$REQUEST_URI");
Joe
biggrin.gif Great! Thanks Willy, I had to make a slight change though, I needed to remove the www. from the beginning.

CODE
header("Location: http://$SERVER_NAME$REQUEST_URI");


Works fine now, cheers smile.gif
Willy Duitt
I'm surprised to learn that the site does not properly resolve when using www.
Willy Duitt
BTW: You do realize that there is a header refresh which would allow you to define the number of seconds before refreshing???
Joe
Nope, I never knew that. Although I did want an instant refresh so I wouldn't need it for this particular script.

For curiosity though, how would you go about setting a time before refresh?
Willy Duitt
QUOTE(joe2kiss @ Jun 23 2005, 11:56 AM)
Nope, I never knew that.  Although I did want an instant refresh so I wouldn't need it for this particular script.

For curiosity though, how would you go about setting a time before refresh?
[right][snapback]29229[/snapback][/right]


Something like this should work:

CODE
header("refresh:5; url=http://www.$SERVER_NAME$REQUEST_URI");


.....Willy
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.