I'm having a lot of trouble with this and I need some expert advice.
Basically said, I want to enter into my database, information about the closing of a page the user, time, etc.
There are several reasons for this need. In the situation I'm talking about, the user is allowed to open the page as needed. But how long the user is on the page is of some importance to management and productivity. And of course there is always the desire to see information about certain pages, so that your content can be used and setup more efficently.
I want to do this when a page closes, upon the pageclose. Now your saying "But PHP is only server side" and doesn't know when the page closes. Your right, and JavaScript will need to be included in my final working bit, probably with the onUnLoad feature. And I can easily call a URL of choice with onUnLoad("http://mysite.com/pageclose.php"), and have done so successfully. And with that call, a new window opens, and that is not acceptable when it's just an informational window for us, and not the user.
So what I am wanting is upon the close of every page, send information into my database about the time, user, etc with PHP about that page close into my MySQL database without a new window opening.
Right now I 2 ways, and neither work to my satisfaction. 1st I have had a pageclose.php called via the onUnLoad to send the data to sql and then have it self.close. Which is simply irritating. 2nd I have created a "redir.php" script that will take either a url passed variable ?user=me.. or read the global session array variables. This works very nice when I want to link into a new page (http://redir.php?pageclose&newurl - etc) But it sucks when someone just closes the window. I mean nothing gets called to tell my database that the page has been closed and at what time, etc. And using both would duplicate the information in the database. So that is why I'm looking for some gurus help me solve this.
I want to tell a page to accept the information I give to it, either by url-var or by global session var, preferably with the onUnLoad function so that at any time (new page or closebrowser) I'll get the information I'm trying to achieve, without a new window.
I mean isn't there a way to simply send data to a site, and if it's valid data, it just uses that data?
I've looked into other solutions and I've seen an .asp solution which uses POST and Microsoft.XMLHTML classes, but I'm using Linux, MySQL and PHP.
Can anyone help?
Thanks
John