sungpeng Posted September 21, 2015 Share Posted September 21, 2015 How to auto go back to previous page without refreshing or pressing any button in php ? Quote Link to comment https://forums.phpfreaks.com/topic/298244-auto-go-back-to-previous-page-without-refreshing-or-pressing-any-button/ Share on other sites More sharing options...
QuickOldCar Posted September 21, 2015 Share Posted September 21, 2015 Can you explain more what you are doing? Am sure is a better way to do whatever is trying to accomplish. You can add a meta refresh to the visited script with a delay and use the referrer as the location. I added a check for the scripts url so does not keep refreshing in a loop. 5 second delay, not sure what doing upon visit <?php $httpreferrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; $this_url = filter_var("http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'], FILTER_SANITIZE_STRING); if (!empty($_SERVER['QUERY_STRING'])) { $this_url .= "?" . filter_var($_SERVER['QUERY_STRING'], FILTER_SANITIZE_STRING); } if ($httpreferrer && $httpreferrer != $this_url) { echo "<META http-equiv='refresh' content='5;URL=$httpreferrer'> "; } ?> If it's some remote site you need to make a script with this code and iframe that website. Many sites block iframes now or have jump out of frame scripts. Quote Link to comment https://forums.phpfreaks.com/topic/298244-auto-go-back-to-previous-page-without-refreshing-or-pressing-any-button/#findComment-1521304 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.