You can’t use PHP to change the header information with the header function after HTML output has begun. If you do, you will get an error like:
Warning: Cannot modify header information - headers already sent by ...
What you can do, midstream, though, is use a meta tag:
echo "<meta http-equiv='Refresh' content='0; URL=location.php?date=".$date."'>";
This is a PHP command that removes all variables from the URL (location.php) except the date. This is useful if you happen to be passing temporary variables, deal with them, and want to remove them from the URL when you are done, without leaving the current page. The 0 is the time before the refresh. More info on this here. A word of warning. The app we are testing this on runs on Firefox 1.0.7. It is an app purely for our usage, and so we don’t really care about whether it works with other browsers, so test this. The idea is valid, though, regardless of your browser, it just might take some further tweaking. Now, this is *not* specific to PHP. Whatever you use to serve up the HTML that can spit out what you specify can send the above. For that matter, at least on our browser, simply embed the meta tag from the above line in a static HTML page, and it should work.
For the complete program that uses this, see this article.