473,813 Members | 4,194 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

redirecting user back from the page he came after login

realin
254 Contributor
hi guys,

this one is simple for you :P

its like.. after login how would i redirect the user back to the page he came from ..

first i have to choose a language ?
shall i do it in JS or php using window.location or header respectively ?

Second thing i want to know is how to send the URLs from one page to another, shall i use an array which is passed on everypage ? or i should use a hidden field ?


thanks and regards
Realin !
Oct 18 '07 #1
2 3777
Atli
5,058 Recognized Expert Expert
Hi.

You could save the $_SERVER['HTTP_REFERER'] url on entering the login page, and then redirect to that url once the login form has been submitted and processed.

Something like:
Expand|Select|Wrap|Line Numbers
  1. # Check if the form has been submitted
  2. if(isset($_POST['formSubmitButton'])) {
  3.   # Process the form
  4.  
  5.   # Redirect
  6.   header("Location: ". $_SESSION['loginRedirect'];
  7. }
  8. else {
  9.   # Save the referer URL
  10.   $_SESSION['loginRedirect'] = $_SERVER['HTTP_REFERER'];
  11.  
  12.   # Print your form
  13. }
  14.  
  15.  
  16.  
Oct 18 '07 #2
realin
254 Contributor
Hi.

You could save the $_SERVER['HTTP_REFERER'] url on entering the login page, and then redirect to that url once the login form has been submitted and processed.

Something like:
Expand|Select|Wrap|Line Numbers
  1. # Check if the form has been submitted
  2. if(isset($_POST['formSubmitButton'])) {
  3.   # Process the form
  4.  
  5.   # Redirect
  6.   header("Location: ". $_SESSION['loginRedirect'];
  7. }
  8. else {
  9.   # Save the referer URL
  10.   $_SESSION['loginRedirect'] = $_SERVER['HTTP_REFERER'];
  11.  
  12.   # Print your form
  13. }
  14.  
  15.  
  16.  

thanks a lot, taht was helpfull.. will look forward to it
Oct 24 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

25
2701
by: Rob Tweed | last post by:
Two inter-related questions: If I'm in PHP page a.php, and I want to switch control to page b.php, the only mechanism I've come across is to use header('Location: someURL") ; This has two drawbacks - it seems inefficient to me - you essentially have to "bounce" a request/response off the browser to switch between PHP pages - leaving and returning to PHP just to switch pages, and also it uses the GET method and, I'd assume, therefore...
4
435
by: TG | last post by:
Hi, I have a question concerning redirecting users who have logged in using our login page. Once they have properly filled out the form they should be redirected back to the last page they were viewing. Is there a way to do this in ASP.NET/VB.NET? Thanks TG
1
7717
by: Stu | last post by:
Hi All, I have an ASP.NET application to which I have implemented forms authentication to handle security. It is a relatively straight forward solution with all aspx pages residing in the root folder. The issue I am experiencing is that when the authentication time out is activated and the user is hence unauthenticated, the browser window is on sometimes redirecting back to the login page. When the browser does or doesn't redirect to...
1
2199
by: AVance | last post by:
Hi, I've come across this scenario in ASP.NET 1.1 with forms authentication where the forms auth doesn't seem to timeout correctly, nor redirect to the login page. I have done some testing, and I believe I've found a solution, but I would like some insight from Microsoft on whether the code I've implemented is correct, and why it is even working. Here is my scenario:
9
1856
by: Denise | last post by:
I have posted a similar message in 2 other forums but got no response. I have spent more hours than I can count researching this. Can anyone provide some insight...? Our ASP.Net application needs to transparently log a user on to a separate secure web site (PHP - not controlled by us). We want to save the user the step of typing in his username and password and having to press submit. I could accomplish this by using the <form...
1
3778
by: Jeremy Chapman | last post by:
I have built a web app. While testing I have found that if I browse to a page in the app, then get redirected to the login page and enter my credentials. The FormsAuthentication.RedirectFromLoginPage call is redirecting to the default.aspx page rather than the original page the user was at. Here is the details of my application: Web.config: <authentication mode="Forms">
41
3255
by: amygdala | last post by:
Hello all, I have posted a similar question in comp.lang.php in the past, but haven't had any response to it then. I kinda swept the problem under the rug since then. But I would really like to resolve this issue once and for all now. The problem might be PHP related but since I only develop applications using PHP, I'm not a hundred percent sure. Therefor I've taken the liberty to crosspost to comp.lang.php and alt.www.webmaster. I...
9
2353
by: Jonathan Wood | last post by:
I've spent days trying to come up with a solution. I'd appreciate it if anyone can help. My site requires all users to log on. There are three different roles of users, and each user type will have access to a completely different set of pages. "Client" pages are in the root folder and "Admin" and "Trainer" pages each have their own subfolders. The problem is that when a user goes to the domain, I want to redirect "Admin" and...
0
1160
by: Anup Daware | last post by:
Hi All, I am facing this very weird issue, for every server request my control is redirecting to the login page and again coming back to the actual page from where the request was initiated when I set my custom Remember be cookie on the login page. Following are the details: 1. Authentication mode is ‘Forms’ 2. This issue is reproducible only in deployed applications, I found this using my trace and remote debugging 3. This issue occurs...
0
9734
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10406
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10420
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10139
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3881
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3029
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.