...

View Full Version : I need a timer..



LuKee
08-26-2009, 02:21 PM
Hey, I'm in need for a PHP timer that will count the time taken for a person sat on a page.

Here's the best example I can get you:
Someone goes to a sertain page, say timer.php and on that page, there is a questionaire that they need to fill in. When they click Submit, I want it to be sent with the answers that they filled in.

If you nee anymore specificness, I shall try my hardest to reply.

Thanks.

Phil Jackson
08-26-2009, 02:28 PM
stamp the time ie time(); (curently will display 1251289587)
post it with the form i.e
page.php?time=<?php echo time(); ?>

then use time again on page.php (now would be 1251289686) and compare the difference. Look up time() on www.php.net



<?php

if(isset($_POST['submit']))
{
if(isset($_GET['time']))
{
$difference = (time()-$_GET['time']);
echo "Time diff in seconds: ".$difference." secs";
}
}

?>

<form method="post" action="index.php?time=<?php echo time(); ?>">
<input type="submit" name="submit" value="submit">
</form>


or more:



<?php

if(isset($_POST['submit']))
{
if(isset($_GET['time']))
{
$difference = (time()-$_GET['time']);
if($difference>=3600)//1 hour
{
echo "Sorry timed out";
}
else
{
echo "Time diff in seconds: ".$difference." secs";
}
}
}

?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum