biwerw Posted July 27, 2009 Share Posted July 27, 2009 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! Link to comment https://forums.phpfreaks.com/topic/167623-redirect-a-user-depending-on-their-login-username-and-password/ Share on other sites More sharing options...
vineld Posted July 27, 2009 Share Posted July 27, 2009 You simply set up a normal login system with various privilege levels which are then assigned to the users. Or did you mean that each user is to have a unique page? Link to comment https://forums.phpfreaks.com/topic/167623-redirect-a-user-depending-on-their-login-username-and-password/#findComment-883963 Share on other sites More sharing options...
methomps Posted July 27, 2009 Share Posted July 27, 2009 I would have my database table setup like this: username password location When they login, pull the location and use header() to redirect them there. Link to comment https://forums.phpfreaks.com/topic/167623-redirect-a-user-depending-on-their-login-username-and-password/#findComment-883965 Share on other sites More sharing options...
biwerw Posted July 27, 2009 Author Share Posted July 27, 2009 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 Link to comment https://forums.phpfreaks.com/topic/167623-redirect-a-user-depending-on-their-login-username-and-password/#findComment-883993 Share on other sites More sharing options...
vineld Posted July 27, 2009 Share Posted July 27, 2009 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. Link to comment https://forums.phpfreaks.com/topic/167623-redirect-a-user-depending-on-their-login-username-and-password/#findComment-884013 Share on other sites More sharing options...
biwerw Posted July 27, 2009 Author Share Posted July 27, 2009 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. Link to comment https://forums.phpfreaks.com/topic/167623-redirect-a-user-depending-on-their-login-username-and-password/#findComment-884016 Share on other sites More sharing options...
vineld Posted July 27, 2009 Share Posted July 27, 2009 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. Link to comment https://forums.phpfreaks.com/topic/167623-redirect-a-user-depending-on-their-login-username-and-password/#findComment-884021 Share on other sites More sharing options...
biwerw Posted July 27, 2009 Author Share Posted July 27, 2009 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; } ?> Link to comment https://forums.phpfreaks.com/topic/167623-redirect-a-user-depending-on-their-login-username-and-password/#findComment-884041 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.