Hello.

I have a problem I can't figure out on my own. I want to create a JS/AJAX function which counts down for exactly 10 seconds (for example), and then it performs an action - calls a .php file, and loads its content in a div element.

The main problem is - users can simply edit the JS and set the 10 second timer to 1 second, for example.

I wonder if there is a way to work this out in JS? I want the 10 seconds to be "set in stone".

I guess I could achieve similar effect by using database, and comparing the time when script started/ended.

Any ideas? I need someone to point me in the right direction.

Thanks in advance.

If you want to prevent the user from modifying it on the front end you could do as you suggested: Have the timer on the front end (Javascript) but also validate the start and end times on the server. Using both methods would be the way to go. Any time you're expecting input from the user (even if it's just time) always validate on both sides.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.