As you correctly found out, the onUnload handler would be the place to do this, something like this:
Within your page, have a hidden form: <form name="oncloseform" action="onclose.php"> <input type="hidden" name="any_data_you_want_to_pass" value=""> </form> In your <body> statement you'll have <body onUnload="document.oncloseform.submit();"> Be aware that this will trigger _always_ if the user leaves the page, regardless if he closes the browser, or goes to another page (even within your own site). Having JS disabled will also inhibit transmission of the form. ----- Original Message ----- From: "Edward Peloke" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, February 05, 2003 2:33 PM Subject: [PHP] writing to the db on close > Hello, > > I need a way to write a record to the db when the user closes their browser. > How can I do this? I looked last night at the onunload javascript event but > am not sure how that can trigger the php code to enter a row in the db. I > am using sessions so is there a way to write to the db when the session is > deleted? > > Thanks, > Eddie > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php