Jump to content

Redirect back with a page refresh


jonw118

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/137232-redirect-back-with-a-page-refresh/
Share on other sites

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.

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.

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.