Author | Post | ||
sniperkid |
can anyone help me out making a timer it has to be something like. /* they click the link */ $time = /*the time it is now*/ $time2 = /*the time before they can click the link again ($time2 + 2mins)*/ $timedif = $time2-$time if ($time => $time2) { /*you can click it again*/ } else { /* you still have $timedif before you can click it * i know its not proper code but i just did a quick example. Thnx |
||
16.05.2005 07:55:45 |
|
||
Gome |
Not sure what the context is.. Anyways.. if you click the link.. the page reloads.. then you can set a javascript variable with your php script sth like : <?php echo "var time="+time(); ?> and then you can use an onclick in the hyperlink to check the time difference in javascript.. I am not so sure if it is possible in php to stop the page from reloading/redirecting. If you want something like: you click the link and when 2 minuts have been passed you go to good.php and otherwise you go to bad.php.. then you should use something like: <?php $timeNow = time(); $lastClick = $_REQUEST['lastclick']; if($time-$lastClick > 2000) { location('good.php'); } else { location('bad.php'); } ?> Notice: i did not test this.. but i know it should be on top of your script. (location changes http header) Second note: using a request variable isn't enough.. you should use the sesssion array but i don't if you use session etc. |
||
Edited by Gome on 16.05.2005 08:31:40 | |||
16.05.2005 08:27:16 |
|
||
sniperkid |
the var $time2 is added to a database, so its easy to call it. |
||
16.05.2005 08:43:49 |
|
||
sniperkid |
Edit: Doesn't matter all sorted (finally). |
||
Edited by sniperkid on 25.05.2005 09:26:32 | |||
18.05.2005 09:55:00 |
|