on 28/01/03 4:42 PM, Phil ([EMAIL PROTECTED]) wrote:

> I have a PHP page with a form that submits to another PHP processing page.
> On completion of the PHP actions on the processing page, I have echoed into
> the page the javascript action of 'location.href=...' and the location is
> redirected to the PHP form page that starting the process. Both pages take
> data from an SQL server. The problem I'm having is that the the javascript
> always grabs the cached page. I need a newly refreshed page to return with
> updated data from the SQL server. Any suggestions?

In addition to sending the correct no-cache headers (which don't always work
with certain browsers and clients), you could also attach a random string to
the URL as a GET variable, so that the browser thinks it's a NEW, unread
URL.

include this function (straight from the manual) via a function library:
<?
function make_seed() {
    list($usec, $sec) = explode(' ', microtime());
    return (float) $sec + ((float) $usec * 100000);
}
?>

Then to get a random number,

<?
// seed the rand no generator and get a rand value
srand(make_seed());
$randval = rand();
?>

Then you can echo it as a get var or querystring on any URL:

location.href = page.php?r=<?=$randval?>
location.href = page.php?<?=$randval?>


Justin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to