Hello Patrick,

Friday, July 22, 2005, 3:04:04 AM, you wrote:

PB> firstpage.php

PB>   <a
PB> href="secondpage.php?prev=firstpage.php">second_page</a>

PB> secondpage.php

PB>   You came from <?php echo
PB> $_REQUEST['prev']; ?>.
PB>   Go there again? <a href="<?php echo
PB> $_REQUEST['prev']; ?>">yes</a>

Or, you could stash the value in a session. This
has the added advantage that, if the user needs to
resubmit a form due to errors (on a log-in form
for example), then "back" will get them to the
protected page they were trying to access, and not
one of their previous log-in attempts. So before
you go to the next page, you would do something
like...

// start PHP code segment
/**
* Add the current page to a history array stored
* in the current session, but only if the current
* page is not ALREADY the last page in the history
*/
function myHistory() {
  if(!isset($_SESSION)) {
    session_start();
  }
  if(isset($_SESSION['history'])) {
    if(!is_array($_SESSION['history'])) {
      unset($_SESSION['history'];
    }
  }
  if(!isset($_SESSION['history'])) {
    $_SESSION['history'] = array();
  }
  $last_page = count($_SESSION['history']) - 1;
  if(
     ($last_page < 0)
       ||
     ( ($last_page >= 0)
         &&
       (
         $_SESSION['history'][$last_page]
           !=
         $_SERVER['PHP_SELF']
       )
     )
  ) {
    $_SESSION['history'][] = $_SERVER['PHP_SELF'];
  }
}
// end PHP code segment

Yes, it's a more complex solution, especially if
you don't have sessions enabled. But it does give
you more control. Sort of a private browser
history just for your website.

Handy when you're using frames (which I avoid,
BTW) or when you want to auto-generate bread-crumb
navigation bars.

That said, the above is a bit of a simplification
of what I _really_ use, which is a history object,
with assorted functions to store and retrieve
histories, and a data structure to store not only
the URL, but a short descriptive name (to be used
for generating a visual history such as the
previously mentioned bread-crumb trail).


-- 
Best regards,
 Gunther                            mailto:[EMAIL PROTECTED]



Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to