Jump to content

Php+mysql


[dx]
 Share

Recommended Posts

Hi,Is it possible to do mysql query on page unload? So it'll be something like online check. When page loads, it inserts "1" into some coloumn "online" in db., and when page is closed update value to "0". So there's no need to calculate ctime - 10 mins etc.Just if statement.I know to make it to insert into when load page. But this..Chears

Link to comment
Share on other sites

You can capture the onunload event in JavaScript and send an XMLHTTPRequest to a PHP file from a JS function to make the query. Check out the AJAX tutorials.

Link to comment
Share on other sites

Note that the unload event is a bit / very unreliable, so you should always have the timeout as a backup.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...