SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Aug 29, 2007, 00:07 #1
- Join Date
- Nov 2006
- Posts
- 151
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
back to previous page after login..
Dear All,
My program works like this...
when user click on login button in my index.php, login.php will be shown and user requires to enter user name and password.
So when user login successfully, he will be brought back to the previous page (eg index.php in this case, it might be blog.php or other depends from where the user click the login button.)
i know there is a way using this:
Code:header($url); $link = $_SERVER['HTTP_REFERER']; header($link);
how can i get the user back to the page before he go into login form?
thank you!newbie...
-
Aug 29, 2007, 00:13 #2
- Join Date
- Jun 2004
- Location
- California
- Posts
- 440
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Set a new hidden field in your login page with the value being the page to send the user back to. In the simplest case this would be:
Code:<input type="hidden" name="return" value="<?=$_SERVER['HTTP_REFERER']?>" />
Code:header('Location: ' . $_POST['return']);
-
Aug 29, 2007, 00:34 #3
- Join Date
- Nov 2006
- Posts
- 151
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Aug 29, 2007, 09:08 #4
- Join Date
- Nov 2006
- Posts
- 151
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
hmmm.... is it possible to have a back 2 pages function for this?
newbie...
-
Aug 29, 2007, 09:32 #5
- Join Date
- Jun 2004
- Location
- California
- Posts
- 440
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
No... the $_SERVER['HTTP_REFERER'] won't even affect your $_POST['return'] variable. You set the hidden variable on the previous page:
Code:<input type="hidden" name="return" value="<?=$_SERVER['HTTP_REFERER']?>" />
Code:<input type="hidden" name="return" value="/previous_page.php" />
-
Aug 29, 2007, 09:42 #6
- Join Date
- Nov 2006
- Posts
- 151
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
xmitchx,
thanks for your reply again...
maybe i did something wrong in my last try just now..
i'll try out your suggestion again..
thanks ya!newbie...
Bookmarks