Page 1 of 1

Refreash After Header()

Posted: Mon Oct 27, 2003 9:22 am
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]

Posted: Mon Oct 27, 2003 9:31 am
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');

?>

Which Page?

Posted: Mon Oct 27, 2003 9:37 am
by Subliminal
Sorry which page do this go on? the main page or the script?

Thanks for your speedy reply

Posted: Mon Oct 27, 2003 4:01 pm
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.

Thanks,

Posted: Mon Oct 27, 2003 4:12 pm
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.