Zubrag.com
November 18, 2017, 02:30:53 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Password protector - Redirect  (Read 28418 times)
zubrag
Administrator
Hero Member
*****
Posts: 785


WWW
« on: May 25, 2007, 05:58:22 AM »

Following moved from Password Protector comments section.

= Kory
Great script!! I love it!!

My only question is if the script can be made to reflect on different users; for example: if "Bob" logs in then I want it to show "Bob's" page. Or if "Fred" logs in, then I want it to show "Fred's" page.
Thanks!!

= AJ
@ KORY:

go to the forums. zubrag, some others and myself have got that covered. you just add:

$REDIRECTS = array (
'username1' => 'PATH_TO_PERSONAL_PAGE',
'username2' => 'PATH_TO_PERSONAL_PAGE'
);

etc etc

underneath 'login details' in the password_protect script

= Kory
Thanks AJ! But, the script fails to redirect to a php page, all it does is redirect to the root of the site when it's set to redirect to thefile.php. But, it does work with HTML files, unfortunely those don't let me set up protection on them, only the php files let me do that. I am stuck. Any suggestions??

= Kory
Update to previous post:

I finally figured it out!
I am doing a HTML post to password_protect.php file, it leaves a cookie if the password is good, it then redirects to another php file that is set to be secured with password_protect_2.php which has the same usernames and passwords but does not make the file redirect. This work-around works great!! I hope that may help somebody with the same problem! Thanks again!!!

= Daniel K       to: Kory
I've been stuck same place as you, is it possible you could upload/send the work-around?

= Kory
In response to the question from Daniel K:
First: you need to have two files: password_protect.php and password_protect_2.php (or just name them whatever)
Assuming you have a user called "testuser" you need to make another PHP file called testuser.php (the name doesn't really matter, just something that you can link to) That is the page that the script will re-direct to when the user logs in.
The following directions apply to the pasword_protect.php file:
Put this after your the $LOGIN_INFORMATION ..... );
$REDIRECTS = array(
'testuser' => 'testuser.php'
);
and this just before the end of the script
header('Location: http://www.example.com/'.$REDIRECTS[$login]); exit;

Now you have the password_protect.php file set up. If the user enters the right username and password, then it will leave a cookie on the user's computer and redirect to the user's own page. Now we need to setup password_protect_2.php.
It needs to be exactly the same as the password_protect.php file, but it needs to exclude the redirect commands that you just put into the password_protect.php file.
If you don't have the same passwords and users in both files this won't work. The last thing you need to do is to go to password_protect_2.php?help and enter that line into the user's php page. If you don't, you will be re-directed to the home directory of your site. I hope that clears everything up: if you need to, please send me an email, my email address is mactip[-at-]gmail.com -Kory

Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC