Jump to content

header('Location: X.php') Question... Going 2 pages back


jonw118

Recommended Posts

Ok,

 

I have a script that if you perform an action, it calls a php file to perform the action... then that php file that is called sends the user to the page specified in the file with the:

 

header('Location: X.php');

 

What I really need it to do is send it back 2 pages... is this possible? I tried using javascript to get it to go back... but that didn't do the trick, just stalled out.

 

Any ideas would be greatly appreciated!

Link to comment
Share on other sites

Studgate... the problem is the page I need it to send back to varies. Basically there are multiple pages that all access one php

file. Once they perform the action I want them sent back 2 pages... and that will vary based on where they came from.

 

Ratcateme... it's not that I'm opposed to JS, I just can't make it work. When I put that in, it just stalls on the php file it calls

(but does perform that action). Here's my code, it's late, am I missing something:

 

edit, I meant to post this is what I have:

header('Location: <script language="JavaScript">window.history.go(-2)</script>');

Link to comment
Share on other sites

header('Location: <script language="JavaScript">window.history.go(-2)</script>');

 

THat is totally wrong.How tec heck would this work however.

 

For every page the user visits make a function that stores in an array the history.

like that

i suppose that you have started the session.

 

function keepHistory()

{

    $history=$_SESSION["history"];

    $history[]=$_SERVER["PHP_SELF"];

    $_SESSION["history"]=$history;

}

 

call this stuff at every page that user sees.

then you would just do something like that

$history=$_SESSION["history"];

 

header("Location : $history[Elements of array -2]");

Link to comment
Share on other sites

I'd recommend something along the lines of what Parhs is showing you..

 

But you should be able to use:

 

header("Location: javascript:window.history.go(-2);");

 

** Not tested - plus it requires the user to have JS enabled..

 

A

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.