TitusRevised Posted July 5, 2006 Share Posted July 5, 2006 Is there any php function that will run only when the page is left.I want a table in my mysql database to erase specific rows once the user leaves the page.Is this possible?Help is much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/13760-run-script-on-page-leave/ Share on other sites More sharing options...
Koobi Posted July 5, 2006 Share Posted July 5, 2006 this would be a client side trigger so you would have to use JavaScript.i would not use this approach though. many things can go wrong...the user could close the browser or kill the browser process on his OS, the browser could crash, the ISP could drop his connection. too many uncertainties in my...but who knows, maybe someone knows something i don't and this is possible but as far as i know, i don't think this is a good solution. Quote Link to comment https://forums.phpfreaks.com/topic/13760-run-script-on-page-leave/#findComment-53449 Share on other sites More sharing options...
TitusRevised Posted July 5, 2006 Author Share Posted July 5, 2006 [quote author=Koobi link=topic=99548.msg392058#msg392058 date=1152121255]this would be a client side trigger so you would have to use JavaScript.i would not use this approach though. many things can go wrong...the user could close the browser or kill the browser process on his OS, the browser could crash, the ISP could drop his connection. too many uncertainties in my...but who knows, maybe someone knows something i don't and this is possible but as far as i know, i don't think this is a good solution.[/quote]Well, the the page information wil be saved in a session so if they close browser then no need to execute a script. But if they navigate away from that single page, then I need a script to run first then send them to where they want to go. If it has to be done in JavaScript, can anyone direct me to help? Quote Link to comment https://forums.phpfreaks.com/topic/13760-run-script-on-page-leave/#findComment-53455 Share on other sites More sharing options...
Koobi Posted July 5, 2006 Share Posted July 5, 2006 oh ok then you can do something here. sorry i misunderstood your first post.in this case i think the safest thing to do would be to have an intermediate page that redirects the user to their requested page.so your user wants to go from one.php to two.php and the moment he leaves one.php, you want the script to execute.the link he clicks would take him to intermediate.php and this script's job is to redirect the user to the requested page based on certain conditions.these conditions could be the execution of your query for example.so you would have a session variable that tracks URL's and the moment this changes, you would execute this query of yours and then redirect him from this page (i.e. intermediate.php) to two.phphope that made sense. Quote Link to comment https://forums.phpfreaks.com/topic/13760-run-script-on-page-leave/#findComment-53459 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.