Question

i have a game whene the user can win something. as soon as he wins he has 60 seconds to fill in his adress name etcotherwise he lose his price and someone else can take it. when he not fills in the adress in 60 seconds then he gets redirected to a sorry too late page and he lose his price. when he fills in his adress he gets redirected to a confirmation page and can claim his price.

i made this with php and the counter is in javascript. the javascript will do the redirect when time = 0

how can i controll that the user either goes to the confirmation page or to the soory to late page. i'm wondering how i can be sure that the javascript countdown is really counted to zero even wehn the users leaves the page.

thanks a lot

Was it helpful?

Solution

try not to trust only javascript for this job, use php to write the time in the session or an database when the user gets the form to fill in his data - check the difference (with php) between this starting-time and the end-time when the user submits the form to the server and show him the confirmation when diff<=1min or show him sorry-to-late when diff>1min

OTHER TIPS

You can't be sure - your users can easily modify your javascript to increase the time limit or even disable the timer completely.

The time limit should be validated on the server. I would suggest that when the time limit starts the server stores a row in the database storing which user it is and when the time limit started. When the user submits the server should check the database to see how much time has passed.

I also think that having just 60 seconds to fill in your address is rather harsh, but that's your decision.

you could do this, use javascript for user interfase, and when user leaves a filed execute ajax call to php script and save data that he just entered in field. And real counting make in php, so when user submits final data u should also check if time expired in php.

I think this is good solution for your problem.

If you do this in Javascript, anybody can read your script and find where the prize page is.

Instead, run your timer with PHP using microtime(). You can start when they see the "You Win" page. It will run in the background, and won't depend on any user interaction.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top