Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Redirect to the page requested before login

Posted on 2009-05-03
2
Medium Priority
?
507 Views
Last Modified: 2013-12-13
Hi experts,
Please help me solve this problem:

Suppose a user tries to access 'http://localhost/dir A/restricted.php' page. Since the user is not logged in, he is redirected to 'login.php' page.
Once the user logs in successfully, he is redirected to the page he previously requsted that is : 'http://localhost/dir A/restricted.php.'

Please help me know, how can i implement this redirection to the previously requested page after the user logs in?

Thanks
0
Comment
Question by:sandhya01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 250 total points
ID: 24290691
When you check access and decide you need to redirect to login.php, either set a session variable or include the url of the page in the url to login.php. Then in login.php, check if this session/url variable exists, if so, redirect to that page after a successfull login. If you use the url variable emthod, you must also put it as a hidden variable on the login form, and fetch it after login so that you know where to redirect. Remember to use urlencode() when you put an url within the url.
0
 
LVL 10

Assisted Solution

by:stormist
stormist earned 250 total points
ID: 24290749
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question