login

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ohnder
Forum Newbie
Posts: 1
Joined: Tue Feb 08, 2005 1:07 pm

login

Post by ohnder »

I'm rather new to PHP.. so this may be a simple question..
I have a members area..which works fine.. but after login (from any restricted page) the user is sent to the front page:
<META HTTP-EQUIV=Refresh CONTENT="2; URL=index.php">
This line is included in one of the config files.

Can I somehow sent them to the page they were accessing in first place?

Thanks in advance!
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it's best to avoid relying on http_referer, as it's an optiona request header component.

When I have needed to redirect back to page of incep, I passed the url to redirect back to.. either encoded via some method or not..
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

what I do is include an "application.php" file on all of my pages I want secured.

In there I set session vars. If the loggedin session var isn't set then I send them to the login screen and pass the page they were on in the url string. Then when they log in, I point them to the page they were on.

see code ex. below:

Code: Select all

<? 
error_reporting(E_ERROR);
if(!isset($_SESSION&#1111;"loggedin"]))&#123;
	$location = "http://".$_SERVER&#1111;"SERVER_NAME"].$_SERVER&#1111;"PHP_SELF"].(isset($_SERVER&#1111;'QUERY_STRING']) ? '?' . $_SERVER&#1111;'QUERY_STRING'] : '');
	
?>
Burr
Post Reply