Refreash After Header()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Subliminal
Forum Commoner
Posts: 40
Joined: Thu Oct 23, 2003 8:12 pm

Refreash After Header()

Post by Subliminal »

Hey,

I have a script that passes data to a script (POST) that changes then value in a mysql field and then uses header() to return to the page when the user started the change. Now in some browsers when we are returned to the page it does not change the value unless you hit the refreash button. (so essentially it is just like hitting the back button) Is there any way for the page to refreash using header() or another way????

Thanks A Million,

Newbie[/i]
hedge
Forum Contributor
Posts: 234
Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada

Post by hedge »

send these headers on the page so cacheing will be disabled:

Code: Select all

<?php
   header('Pragma: no-cache');
   header('Cache-Control: no-cache, must-revalidate');

?>
Subliminal
Forum Commoner
Posts: 40
Joined: Thu Oct 23, 2003 8:12 pm

Which Page?

Post by Subliminal »

Sorry which page do this go on? the main page or the script?

Thanks for your speedy reply
evilMind
Forum Contributor
Posts: 145
Joined: Fri Sep 19, 2003 10:09 am
Location: Earth

Post by evilMind »

You could safely place this on both (if I understood your initial question correctly):

Code: Select all

<?php
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// Make sure that you send your headers *before* you display anything to 
//  the page( ie, before you echo())
//.... Your Code below ......
?>
see php.net/header and http://www.w3.org/Protocols/rfc2616/rfc2616 for more information.
Subliminal
Forum Commoner
Posts: 40
Joined: Thu Oct 23, 2003 8:12 pm

Thanks,

Post by Subliminal »

You Rock... great thanks guys... I was putting the headers after the echo() so it didn't work. Thanks very much...

I tried your code evilMind but it didn't work - the code provided by hedge did though.. i put them in both the same spots is their a large difference?

Thanks again... this is a great network BTW... I hope to be able to contribute soon enough.
Post Reply