|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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!![]() |
|
#2
|
||||
|
||||
|
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.
|
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
...keep in mind that HTTP_REFERER is blocked by many newer browsers.
![]() |
|
#5
|
|||
|
|||
|
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
|
|
#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 |
|
#7
|
||||
|
||||
|
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. |
|
#8
|
||||
|
||||
|
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. |
|
#9
|
||||
|
||||
|
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 =) |
|
#10
|
||||
|
||||
|
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! |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Creating a login screen need to redirect to previous url |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|