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
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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.