Jump to content

Redirect a user depending on their login username and password


biwerw

Recommended Posts

I would like to setup one main login page for multiple clients, but depending on what username and password they login with it directs them to different pages.

 

Anyone know how I would set this up or someplace I can find a reference script?

 

Thanks!

I will be setting up 5 users and each one will be taken to a unique page.

 

I'm not very familiar with coding php from scratch so if anyone could point me in the direction of something that has already been done that would be awesome.

 

Thanks

There are plenty of log in script examples, just search.

 

I'm not sure what you're trying to accomplish though, are these pages completely unique or do they just display some content that is linked to each specific user? Normally the location field mentioned above would be completely unnecessary.

Each page will be completely unique (ie branded for each individual client).

 

I have found plenty of php login scripts but none that give you the option to change the successful login page based on the user that has logged in.

Each page will be completely unique (ie branded for each individual client).

 

I have found plenty of php login scripts but none that give you the option to change the successful login page based on the user that has logged in.

 

Ok, then simply add the location field (or filepath or whatever you wish to call it) to the members / users table. When a user logs in you simply redirect them to the page found in the location field (look at PHP headers for that redirect). You will need to adjust this though if the unique pages are to be secret, that is none other than the specific user is to access them. Then you should think about another solution than what I suggested.

Here is what I have been experimenting with but am unsure how to correctly make the code goto the desired page.

 

<?php

$usernames = array("user1", "user2", "user3", "user4");

$passwords = array("pass1", "pass2", "pass3", "pass4");

$page = array("mypage1.php", "mypage2.php", "mypage3.php", "mypage4.php");

 

 

 

for($i=0;$i<count($usernames);$i++){

  $logindata[$usernames[$i]]=$passwords[$i];

}

if($logindata[$_POST["username"]]==$_POST["password"]){

session_start();

$_SESSION["username"]=$_POST["username"];

header('Location: '.$page);

exit;

}else{

header('Location: login.php?wrong=1');

exit;

}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.