sciencebear Posted October 22, 2009 Share Posted October 22, 2009 I have a page that process some mysql queries which all work fine, but I'd like for the page to redirect the user to the previous page when they are done. What code can I use to do this? Quote Link to comment https://forums.phpfreaks.com/topic/178607-solved-redirect-to-previous-page/ Share on other sites More sharing options...
JonnoTheDev Posted October 22, 2009 Share Posted October 22, 2009 use a header // run mysql query $result = mysql_query("blah...."); // redirect user header("Location:page1.php"); exit(); Quote Link to comment https://forums.phpfreaks.com/topic/178607-solved-redirect-to-previous-page/#findComment-941999 Share on other sites More sharing options...
sciencebear Posted October 22, 2009 Author Share Posted October 22, 2009 use a header // run mysql query $result = mysql_query("blah...."); // redirect user header("Location:page1.php"); exit(); I've used header before, but the users will be coming from different pages, not just one. Edit: nevermind, I figured it out. I used: header('Location:'.$HTTP_SERVER_VARS['HTTP_REFERER']); Quote Link to comment https://forums.phpfreaks.com/topic/178607-solved-redirect-to-previous-page/#findComment-942001 Share on other sites More sharing options...
JonnoTheDev Posted October 22, 2009 Share Posted October 22, 2009 The referring page is stored in $_SERVER['HTTP_REFERER'] header("Location:".$_SERVER['HTTP_REFERER']); exit(); $HTTP_SERVER_VARS is depreciated Quote Link to comment https://forums.phpfreaks.com/topic/178607-solved-redirect-to-previous-page/#findComment-942004 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.