Re: returning to the same page after log in

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, August 9, 2006 8:18 am, Sjef wrote:
> Hello all!
> This is a bit difficult to explain.
> On a site I am building I sometimes use the GET method to forward
> values to
> the next page. There are certain pages that you need to be logged in
> to to
> be able to see data. So you arrive at the page, you realize that you
> are not
> logged in, so you type your username/password and hit 'log in'. Then
> the
> page gets severely messed up as the GET data are not forwarded (at
> least, I
> think that's the problem). Any ideas how to solve this?
> I tried to send a header("location: ...") with the document_root and
> request_uri as the location, but that doesn't do the trick.

In the ideal world, you'd be using PHP session_start to handle the
login, so their login would persist, and you'd never hit this problem.

Assuming you've done that, but their session times out, or, perhaps,
you are forwarding from some place that requires no login, and they
weren't logged in, you would need to change the LOGIN routine to
accept a parameter of the URL of where they were trying to go.

$_SERVER['PHP_SELF'] and $_SERVER['REQUEST_URI'] and friends would do
that.

After a successful login, you could just do a header("Location: ")
back to the URL they wanted in the first place.

An even simple option, often, is to avoid all the header("Location: ")
bouncing around, and just include() whatever it is they should be
getting.

And if you include 'login.inc' and THAT file can simple check their
credentials and do nothing, or put out a FORM to POST back to the same
page and then exit, you can often avoid the header("Location: ")
entirely.

This can make debugging and following process flow through the
application a heck of a lot easier, since you're not trying to
de-construct URLs and figure out where you're getting bounced to all
the time.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux