Current location: Hot Scripts Forums » Programming Languages » PHP » Redirect previous 2 pages after login


Redirect previous 2 pages after login

Reply
  #1 (permalink)  
Old 12-31-04, 03:25 AM
mcrob mcrob is offline
Coding Addict
 
Join Date: Jul 2004
Posts: 266
Thanks: 0
Thanked 0 Times in 0 Posts
Redirect previous 2 pages after login

Whats up guys. I wanted to do this. The pages that are password protect right, if someone is not logged in and they enter in a link that goes too a post page for example, it will redirect them to the login page. I wanted too do this. After a user logs in, it will redirect them previous 2 pages so then they get redirect too the new post page. Just like this website for example too. If you not logged in and you click on new post, then it redirects you too the login page. After your login is success, it first forwards you to the Login Successful page, then it like redirects you too the previous 2 pages, then you can make a new post. I hope someone can help
__________________
Visit my Online Blog
http://www.robslounge.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 12-31-04, 09:44 PM
mcrob mcrob is offline
Coding Addict
 
Join Date: Jul 2004
Posts: 266
Thanks: 0
Thanked 0 Times in 0 Posts
?? Nobody. There has to be at least one guy that knows on here!
__________________
Visit my Online Blog
http://www.robslounge.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 01-01-05, 03:17 AM
Sabu Sabu is offline
Junior Code Guru
 
Join Date: Sep 2004
Posts: 458
Thanks: 0
Thanked 0 Times in 0 Posts
I wanted to help too move two pages back, but.. what are you talking about? Two pages? You can redirect from one page to another, and the nature of pages lets you move in this one step, what's with the massive paragraph about moving two?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 01-01-05, 03:21 AM
mcrob mcrob is offline
Coding Addict
 
Join Date: Jul 2004
Posts: 266
Thanks: 0
Thanked 0 Times in 0 Posts
So can you do it, and the reason for the big paragraph is too be more specific on what Im talking about
__________________
Visit my Online Blog
http://www.robslounge.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 01-01-05, 03:51 AM
Sabu Sabu is offline
Junior Code Guru
 
Join Date: Sep 2004
Posts: 458
Thanks: 0
Thanked 0 Times in 0 Posts
Pay close attention to the words I'm highlighting in bold.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 01-01-05, 08:35 AM
mikaelf mikaelf is offline
Wannabe Coder
 
Join Date: Jun 2004
Location: php[dot]net
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
a simple example:
PHP Code:

//Password protected file (e.g: secret.php)

...
if(!
isLogin()) { //isLogin is user function which returns bool
   
header('Location: login.php?next='.$_SERVER['PHP_SELF']);
}

//Your login.php
//Assume your form template is like this:
//login.tpl
//<form action="{SECT.ACTION}" method="post">
//       <input type="text" name="login" value="{SECT.LOGIN}" />
//       <input type="password" name="pass" value="{SECT.PASS}" />
//       <input type="hidden" name="redirect" value="{SECT.REDIRECT}" />
//       <input type="submit" value="Submit" />
//</form>
//Assume you have template parser object $tpl

//No error condition
$tpl->setTemplate('/path/to/tpl/login.tpl');
$tpl->setSection('SECT');
$tpl->updateTemplateValue('LOGIN','');
$tpl->updateTemplateValue('PASS','');
$tpl->updateTemplateValue('REDIRECT',$_GET['next']);
$tpl->print();

//Your {SECT.ACTION}
//Validate user input
//If all are valid, continue
if($valid) {
   
$dest = ($_POST['redirect'] != '') ? $_POST['redirect'] : 'home.php';
   
header('Location: '.$dest);
   exit();

regards,
__________________
Useful PHP links:
bugs.php.net - for reporting PHP bugs
pear.php.net - PHP extension and application repository
pecl.php.net - get non standard PHP modules, submit yours
www.phpclasses.org - PHP classes repository
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Login and Redirect user script alistairgd Script Requests 4 01-03-05 04:30 PM
mysql multi user login for restricted pages giano PHP 7 12-07-04 06:04 AM
how to link to insert pages samkry ASP 0 06-14-04 12:14 AM
HELP! Php to login to HTACCESS? godfather PHP 4 03-06-04 01:03 AM
Help! Need to redirect to pages based on posted form data big_t8r ASP 1 12-09-03 06:39 AM


All times are GMT -5. The time now is 09:10 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.