View Full Version : Login Script to redirect to Original page
Bengal313
02-28-2011, 09:24 PM
I am trying to implement a simple login script into some of my php pages. I am using this script,
http://www.phpeasystep.com/phptu/6.html
Can some help me alter this so that after successful login I need the page to redirect to the original page (the password protected page)
Thank you
Beverleyh
03-01-2011, 12:00 AM
So you want the page to redirect back to main_login.php regardless?
In login_success.php, before the closing php tag ( the ?> part )
else {
header('location: main_login.php'); // or another page of your choice
}
Bengal313
03-01-2011, 01:35 AM
No, I have multiple pages that password protected. So, if a user visits the page it needs to direct them to a login page, and then after logging in correct directly them back to the page that was password protected.
Beverleyh
03-01-2011, 10:11 AM
So you want to redirect back to the page they came from, which could be any number of pages (each different)?
Try putting a hidden redirect field in the login form;
<input type="hidden" name="redirect" value="redirect.php">
And this line in the "redirect.php" page referenced in the value attribute above;
<?php header('Location:' . $_SERVER['HTTP_REFERER']);?>
I use this method on a website that has a login panel on every page -
If not logged in, the visitor only see's "general" content.
If logged in, the visitor see's the "general" content plus extra members content.
However, I dont think this method will work if the user has to go to a specific login page to login (where the login panel isnt integrated into the main pages of a website)
Give it a try though.
Bengal313
03-01-2011, 07:16 PM
No luck. I tried it and didn't work. I have a separate login page. God, something so simple. I'm just going to look for another script that does the redirect. Any suggestions?
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.