Re: writing to the db on close

From: Date: Wed, 05 Feb 2003 16:23:17 +0000
Subject: Re: writing to the db on close
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-134432@lists.php.net to get a copy of this message
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" <epeloke@echoman.com> To: <php-general@lists.php.net> 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 >

« previous php.general (#134432) next »