jonw118 Posted December 16, 2008 Share Posted December 16, 2008 Hello! I made post yesterday about wanting a php file with the header(Location... to go back 2 pages. But doesn't sound like that can happen. SO- my new resolution is this. When someone fills out a form and it calls the PHP file to redirect them to a page, I created a "Thank You Page" of sorts. On that page I am placing a link "Go Back". Basically I want them to go back to a certain page (2 pages back). BUT, when they go back, I need that page to auto refresh to show the content they provided updated. Right now I'm using window.history. It's taking them back, but it is not refreshing the page to show what they just posted. I've tried all sort of js methods, to no avail. I'm curious if this can be accomplished in php? THANKS so much for any advise. Quote Link to comment https://forums.phpfreaks.com/topic/137232-redirect-back-with-a-page-refresh/ Share on other sites More sharing options...
limitphp Posted December 16, 2008 Share Posted December 16, 2008 If you want them to go back two pages and have that page refresh, isn't that the same thing as just taking them to that page to begin with? Whats wrong with redirecting them there to begin with? Quote Link to comment https://forums.phpfreaks.com/topic/137232-redirect-back-with-a-page-refresh/#findComment-716938 Share on other sites More sharing options...
jonw118 Posted December 16, 2008 Author Share Posted December 16, 2008 If you want them to go back two pages and have that page refresh, isn't that the same thing as just taking them to that page to begin with? Whats wrong with redirecting them there to begin with? No... there are a lot of different pages that have forms on them that all use this same (single) php script to process. After that script processes them I want them to go back where they came from. Quote Link to comment https://forums.phpfreaks.com/topic/137232-redirect-back-with-a-page-refresh/#findComment-717020 Share on other sites More sharing options...
premiso Posted December 16, 2008 Share Posted December 16, 2008 One option is to use sessions, record what page it came from and redirect back. The other option is to use Javascripts history.go(-1) feature, but if you are posting data, that can be messy. I would suggest the sessions, so set like "return_page" to be each page, then just redirect back to that page on success using header I even think that $_SERVER['HTTP_REFERRER'] might even store that information for you. Quote Link to comment https://forums.phpfreaks.com/topic/137232-redirect-back-with-a-page-refresh/#findComment-717028 Share on other sites More sharing options...
Gighalen Posted December 16, 2008 Share Posted December 16, 2008 I agree with premiso. Start a session to store the page, then use a header() function to return to the page. http://www.w3schools.com/php/php_sessions.asp Quote Link to comment https://forums.phpfreaks.com/topic/137232-redirect-back-with-a-page-refresh/#findComment-717030 Share on other sites More sharing options...
jonw118 Posted December 16, 2008 Author Share Posted December 16, 2008 Awesome! Thanks for the help. I am trying to read up on this now how to do it. One other thought, I'm trying to find a tutorial on inserting a "redirect" into the form, where it could just redirect them back to the page I specify. Quote Link to comment https://forums.phpfreaks.com/topic/137232-redirect-back-with-a-page-refresh/#findComment-717045 Share on other sites More sharing options...
premiso Posted December 16, 2008 Share Posted December 16, 2008 header That is probably the best way to redirect in php. Quote Link to comment https://forums.phpfreaks.com/topic/137232-redirect-back-with-a-page-refresh/#findComment-717050 Share on other sites More sharing options...
jonw118 Posted December 16, 2008 Author Share Posted December 16, 2008 header That is probably the best way to redirect in php. Do you (or anyone) know of a resource I could check to learn how to include a hidden field like "redirect" and URL as a value... then in the processing code what I need to put in there to code the redirect? Thanks again for the assistance, much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/137232-redirect-back-with-a-page-refresh/#findComment-717064 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.