• 0

php: Redirect to previous page.


Question

PHP Learners Diary, Day 6:

I have a login and logout script. The script can be called from any page within the entire site.

So how can I make it so that if the user was on Page A and clicked logout, they went back to Page A after the logout, and if they were on Page B they would be returned to Page B after the logout?

I'm aware of the Header ("Location: etc etc... but that doesn't seem to be the appropriate way here as I don't know what page they are calling from.

Thanks in advance, once again, for any help provided.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0
$referer = $_SERVER['HTTP_REFERER'];

header("Location: $referer");

lol That easy huh? Thank, guys, yer helping a php nube no end. Worked first time.

Thanks again.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.