Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
This week, we're updating our course layouts and descriptions. Presentation and materials always gently change over time, but just occasionally there's a need to make a step change to clear out some of the old and roll in the new. That's now happening - but over a long and complex site it's not instant and you'll see sections of the site changing up to and including 19th September.

See also [here] for status update
 
Refreshing a page with PHP

Posted by FloppyShoe (FloppyShoe), 2 March 2004
Hi everyone.  I am a relative newbiw to the world of PHP and programming in general.

I am writing a page that shows the date (and sometimes the time) on a page and my question is this :
Is there a way I can get the page to refresh itself, say every hour or so, so that if someone leaves the page open over-night, it will display the current date when they come back to the computer the following day rather than still displaying the date of the previous day.

I hope that makes sense and more importantly that someone will be able to help!!

Many thanks in advance,

FloppyShoe.

Posted by Chris_Isaac (Chris Isaac), 2 March 2004
hi

if you use the following at the top of the script it will force the browser to reload the page rather than use a cached copy:

Code:
header("Cache-Control:no-cache");




Posted by admin (Graham Ellis), 2 March 2004
I've put up a demo page at http://www.wellho.net/demo/clockpage.php4.   The source code of the page is:

Code:
<html>
<head>
<title>This is a clock page</title>
<<meta http-equiv="Refresh" content="60; URL=clockpage.php4">
</head>
<body>
<h1>This clock page refreshes every minute</h1>
It is now <?php print(date("H:i o\\n l, j F Y")) ?>
<hr>
Graham Ellis, <?php print (date ("Y")); ?>
</body>
</html>


Our server is in West Coast USA, so the report is Pacific time; you can vary that and should do so to suit the timezone of most of your users.

Chris's header shouldn't be necessary on a PHP page if the server is properly set up (but it would do no harm).  On an HTML page that you change frequently, it could be a good addition.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho