Bob Norris Posted January 8, 2007 Share Posted January 8, 2007 Hi, Anybody have an idea how I can clear a txt log on page exit using PHP? They reside in the same folder and the txt file hascorrect permissions. Something like this: function deletelog() Link to comment https://forums.phpfreaks.com/topic/33273-clear-log-on-exit/ Share on other sites More sharing options...
trq Posted January 8, 2007 Share Posted January 8, 2007 What do you meen by page exit? Link to comment https://forums.phpfreaks.com/topic/33273-clear-log-on-exit/#findComment-155412 Share on other sites More sharing options...
Bob Norris Posted January 8, 2007 Author Share Posted January 8, 2007 When the page closes. After someone leaves. Im trying to clear a chat log after they go using php Link to comment https://forums.phpfreaks.com/topic/33273-clear-log-on-exit/#findComment-155416 Share on other sites More sharing options...
Jessica Posted January 8, 2007 Share Posted January 8, 2007 that has to be javascript, or javascript accessing a php script. php runs before the page loads. Link to comment https://forums.phpfreaks.com/topic/33273-clear-log-on-exit/#findComment-155422 Share on other sites More sharing options...
magic2goodil Posted January 8, 2007 Share Posted January 8, 2007 unless the user is logged in with a login system..then when they exit and the session is ended or use your logout function..then the log could be told to clear.. Link to comment https://forums.phpfreaks.com/topic/33273-clear-log-on-exit/#findComment-155424 Share on other sites More sharing options...
trq Posted January 8, 2007 Share Posted January 8, 2007 [quote]unless the user is logged in with a login system..then when they exit and the session is ended or use your logout function..then the log could be told to clear[/quote]Not quite that simply but yes, its possible. Link to comment https://forums.phpfreaks.com/topic/33273-clear-log-on-exit/#findComment-155427 Share on other sites More sharing options...
cshireman Posted January 8, 2007 Share Posted January 8, 2007 You need to do two things. First, setup a javascript function to be called when the page is left. I think this is called onblur or something like that, you can find the exact function name using google. The other thing you need is to have the a PHP script to clear the log. Next, have the javascript function call out to the PHP script using an Ajax http request. You might have to customize the javascript for different browsers, but I know it can work. Link to comment https://forums.phpfreaks.com/topic/33273-clear-log-on-exit/#findComment-155630 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.