Jump to content

Php+mysql


[dx]

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...