matty Posted March 1, 2007 Share Posted March 1, 2007 Hi, Im looking for a way that i can run a function when a user refreshes a page, or clicks back. This is so if a user does either of the above half way through completing a series of events, it will tell them for example they have to start again. The only way i can think of doing this is to insert a value into a table (database) when they start the series of events and then remove it when they have completed, therefore if they goback/refresh or go to another page half way through that value will still be in the database and therefore the function will run. I will have something like if($settings[site] == 'Y'){ page("site"); exit; } At the top of each page. Is there any alternatives? Thanks, Matt Link to comment https://forums.phpfreaks.com/topic/40759-execute-code-when-user-refreshes-or-clicks-back/ Share on other sites More sharing options...
micah1701 Posted March 1, 2007 Share Posted March 1, 2007 sounds like you want to use sessions. <?php session_start(); $this_page = 3; //presuming there were 2 pages before this one. if($_SESSION['last_visited_page'] < $this_page){ $_SESSION['last_visited_page'] = $this_page; }elseif($_SESSION['last_visited_page'] == $this_page){ exit("you've already been to this page"); } ?> Link to comment https://forums.phpfreaks.com/topic/40759-execute-code-when-user-refreshes-or-clicks-back/#findComment-197307 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.