March 21, 2018, 12:37:51 PM *
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]
Author Topic: Direct to different page based on username input?  (Read 7863 times)
Posts: 1

« on: August 19, 2011, 07:44:08 AM »

Hi everyone. I just installed the password protect php script on my website and it works like a charm.
I'm not a programmer so I struggle a lot when it comes down to building a bit more advanced sites, but I'm happy this solution worked for the time being.
I wanted to make a simple client login area, and direct  the client to a page I've setup with a box.net widget, to view project files etc.
This works for a single page, but I was wondering if there could be a way to change the password protect script, so that based on the user name, it redirects to a different page.
Say for example, I'm working on 3 different projects at the same time. I would like to have a different page for each project and depending on the user name my client inputs, he goes to the appropriate page for his project.
I appreciate your help on this. Thanks.

Hero Member
Posts: 785

« Reply #1 on: August 19, 2011, 03:21:29 PM »

You can have different people directed to different pages.

Add redirects list after the $LOGIN_INFORMATION, as follows:

$REDIRECTS = array(
  'username1' => 'http:/www.example.com/folder1/file1.html',
  'username2' => 'http:/www.example.com/folder1/file2.html',
  'username3' => 'http:/www.example.com/folder2/file5.html',

This would define redirect for each user.

Than add following after the unset($_POST['Submit']); line:

header('Location: '.$REDIRECTS[$login]); exit;

but note that every user listed in $LOGIN_INFORMATION will be able to access all the pages protected by this password_protect.php, even though they will be redirected to different pages. But maybe it is ok as they will not know urls of other projects Smiley
Pages: [1]
Jump to:  

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