Forum Moderators: coopster

Message Too Old, No Replies

Login refreshes current page

         

dave1236

5:57 pm on Sep 12, 2006 (gmt 0)

10+ Year Member



All:

Currently, when a user logs into my site, they are directed to a specific page upon success. Now that I have added some depth to my site, I want users to be able to login from any page, and when the login program executes, they are brought back to same page they were at, but in a logged in state.

I believe I can do this by adding a variable that gets called by the header in my login program...I am just unsure how to do so.

Here is what I got...

This is on every page when the user is not logged in...

<b>You are not logged in!</b>
<a href="Login2006.php"><font color="#FFFFFF">Login</font></a>
<br>

here is my header on the login page...

header("Location: welcome.php");

How can I get this header to reflect the referring page?

Thanks!

smells so good

7:20 pm on Sep 12, 2006 (gmt 0)

10+ Year Member



You can get the refering page in your login script, and then return the user to that page.

$url_of_refering_page = $_SERVER['HTTP_REFERER'];
header("Location: $url_of_refering_page");

The exact syntax may need to be tweaked, but that's the general idea.