Page must refresh after seconds set in php variable
I've been through the forum and tried this post (http://stackoverflow.com/questions/7128417/stop-javascript-auto-refresh-after-fix-time-for-example-1-min).
I'm busy with a testing site. Different tests has different time limits, eg test A = 3600 and test B = 2400 which is stored in a table. When the test is started the time is stored in a variable. What I am trying to achieve is that the page needs to refresh after 3600 or 2400 depending on the test or run a script that checks if the time has expired and log the user out.
Can someone point me in the right direction? Currently I am开发者_如何学运维 using
<head>
<meta http-equiv="refresh" content="3600">
which works but how do I change it for test B then?
If you're calculating the time until the refresh in php, using a <meta>
tag to simulate an http header seems a bit weird to me. Just send the header straight away:
<?php
header('Refresh: ' . $timeLimit);
If the refresh interval is in a PHP variable called $refresh
, this should do:
<head>
<meta http-equiv="refresh" content="<?php echo $refresh?>">
If the test A and test B are in two different variables (say, $variableA
and $variableB
) just use the following.
<meta http-equiv="refresh" content="<?php echo $variableA; ?>">
精彩评论