Page 1 of 1

php timer

Posted: Mon Oct 13, 2008 10:51 am
by google
hi

is there any way that i can use to create a countdown timer using php

im designing an online exam and i want to create a secure timer that counts for an hour
i dont want to use javascript in case that it's disabled by the browser



thanks

Re: php timer

Posted: Mon Oct 13, 2008 11:15 am
by papa
meta (refresh) tag maybe. :)

Re: php timer

Posted: Mon Oct 13, 2008 2:17 pm
by omniuni
Create a session variable, and set it to the time that the exam starts. create an iFrame which uses metadata to refresh itself, say, every second, and a php script in this iFrame which reads this session variable and displays time remaining. When time runs out, set a session variable so that when they submit the form after time, the system knows not to count it. As long as they submit before the time limit, it would then grade it and give credit. You could try setting a meta refresh/redirect as stated above to automatically move the user off the page slightly after time is up, but I would still show a clock which gives more accurate indication of time remaining.

-OmniUni

Re: php timer

Posted: Mon Oct 13, 2008 2:43 pm
by VladSun
Use meta refresh:

Code: Select all

 
<?php
$refresh_time = $test_time - time() + $_SESSION['start_time'] > 0 ? $test_time - time() + $_SESSION['start_time'] : 0;
?>
<meta http-equiv="refresh" content="<?php echo $refresh_time; ?>;url=http://exams.com/finished.php">
and of course in your http://exams.com/finished.php check it again (in case the user has tempered the meta tag).

Re: php timer

Posted: Mon Oct 13, 2008 3:05 pm
by google
thanks alot

i will try to implement what you have post and i will tell you what happends

thanks again