General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 20th, 2004, 02:27 PM
GirlGeek GirlGeek is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 2 GirlGeek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Creating a login screen need to redirect to previous url

What i'm doing is checking if someone is logged in before i allow them to enter the member section pages.
I need a way to capture the url they wanted to go to so that if they are not logged in, after they login I can redirect them to the page they were going to.
HELP!

Reply With Quote
  #2  
Old January 20th, 2004, 03:46 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Store the results of getenv("HTTP_REFERER") in a hidden field in the login page. Once they've signed in, if the hidden field is set, send them to that page. Else, send them to your default page.

Reply With Quote
  #3  
Old January 20th, 2004, 04:54 PM
GirlGeek GirlGeek is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 2 GirlGeek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm not sure if i'm doing this correctly. I have...

$url = getenv("HTTP_REFERER");
...
...

if ($url == false) {
header("Location: /members/index.php");
} else {
header("Location: ".$url."");
}

I'm not sure if it's my syntax or logic that is in error.

Reply With Quote
  #4  
Old January 20th, 2004, 05:09 PM
ATL_bones ATL_bones is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: ATL
Posts: 5 ATL_bones User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
...keep in mind that HTTP_REFERER is blocked by many newer browsers.

Reply With Quote
  #5  
Old January 20th, 2004, 08:24 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
i dont know if this would work but if you are loading your pages with something like ?page= try to save that page to a variable then when the user logs in simply refer them to ?page=(variable), ill give it a try to see what happens

Reply With Quote
  #6  
Old January 20th, 2004, 09:23 PM
Mike_r Mike_r is offline
ExoCrew
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 68 Mike_r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Try using a combination of QUERY_STRING and stuff like that ...


$_SERVER['QUERY_STRING'] ... That will give you the file name and its queries

ex: file.php?stuff=stuff&do=do
__________________
ExoHelpDesk
ExoCrew Free Services

Reply With Quote
  #7  
Old January 20th, 2004, 10:34 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
I think DHouston's idea serves the best... on the login form, save the HTTP_REFERER variable in a hidden field...

Either that, or use sessions to utilize state management.

Reply With Quote
  #8  
Old January 21st, 2004, 08:45 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Yeah, you'd have to store the referer (if available) as a hidden field in the login form. If you get the referer from the page that the login form loads, guess what? -- the referer's always going to be the login form. So you have to store the referer that sent someone to the login form, pass it along to the next step, and redirect if the login was valid.

As for people who disable referers, screw 'em. They can just retype the URL in. I didn't know newer browsers were blocking this info.

Reply With Quote
  #9  
Old January 21st, 2004, 10:13 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
I think my software firewall blocks the info sometimes...

Perhaps another way is when you're linking to the form (let's say from page.php... link to login.php?ref=page

Doesn't sound that secure, but its another option =)

Reply With Quote
  #10  
Old January 22nd, 2004, 01:20 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Thought of another option!

Javascript's history!

I think the syntax was:
javascript:history.back(-2)

Combine that with a window.location (somehow?)..
I'm just running this off the top of my head, and its late at night... perhaps in the morning I'll think of the proper code.

Anyways GirlGeek, there are a wealth of options here for you to choose from... let us know which one works for ya!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Creating a login screen need to redirect to previous url


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT