How to make an event when there is a refresh [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm making a web-quiz, there are the users logged in this game and they have to reply to a quiz with 3 alternatives, the problem comes when the user is a bit clever because if he does a refresh all the question change so the user can do this until he find the one that he knows, how can I put in my website (after an alert) wrong question?
example:
USA is in EU
UK is in Africa
France is in EU
If the users does a refresh, how can I show message such as alert("if you refresh is a game over") and save the answer as incorrect in the database?

I'd suggest assigning the question in PHP and storing which question you asked in a $_SESSION variable. That way when they refresh the page you can show them the same question until they answer it.
UPDATE
There is a caveat to this, if your user really is a smarty, they can delete their cookies and refresh the page, which would create a new session for them since session identifiers are saved as a cookie in PHP (by default).

Related

refresh only if changed php-ajax [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
well, I have a comment system that is updated every second with jQuery, but I want to update only if there are changes, that is, only if there are new records in the database. is there a way to do this?
Excuse my English, but I'm using google translator
You may create two function in JS. First function ask php script, which check changes, and, if data changed, run second JS function, which get data and update DOM.
Php is not may send info on loaded http page independently, without request from client side.

how to find user is logged in different browser or different system at a time using php [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am implementing Online Examination System. If user is logged in different browsers at a time it should not be logged in. As well as Different system. Please help me how to restrict the user logging in different browsers. Please give any Example Code. So that i can understand easily. Thanks in Advance.
Try the following logic:
You can keep the username of logged in users in a list. Then each time a new login is made, check if the user is in that list. If it is, then redirect him to the error page else let hime proceed with examination. On logout you will remove the user from the list.

how to use php or js to record the stay time of user in my web site page? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
how to use php or js to record the stay time of user in my web site page?
someone click a link and jump to my website page, he stay in the page for 5 seconds then close the page.
I want to record the 5 seconds to my database , how can I do the job using js or php?
it seems as the same as ga, but I don't know how ga do this.
You can use javascript's setInterval method to periodically send something to your server
For example:
setInterval(function(){
sendToServer()
},1000);

how can I disable copying images from browsing my website [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
There is an option for disabling right click on the website on the computer but on the mobile I don't know which javascript code I would need.
Images have to be copied from the web server to the client system in order for the client system to display them.
There is no way to stop people from saving them.
There is an option for disabling right click on the website
Not one that can't be trivially bypassed.
There's no way to actually block an image from being copied. If it's being shown to the user, they can obtain it. The resource is already sent to them for render anyways.

Detect fake user Agents? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Is it possible to recover if someone is visiting my website using a fake user agent? If yes, can someone please tell me how can find out this information?
Thank you very much!
You can check the user agent from PHP like from this global variable $_SERVER['HTTP_USER_AGENT']. But if someone is using a fake user agent which claims to be something else* it's going to be difficult to spot.
This shouldn't really matter unless they are a hacker who is able to find some security weaknesses in your site and use those to do something nasty like access your database, delete all your data or download your users' credit card numbers.
The solution to the hacker problem is make sure your website is secure.
This is called 'spoofing' as #JAL mentions in his comment above.

Categories

Resources