black_box Posted October 21, 2007 Share Posted October 21, 2007 I m new in PHP i m making a new system to learn PHP .. i want to make a login page and every user will use the same page for login. when they will give user id and password and the system will automatically show different page for different user. Sample: Admin will automatically redirect to admin.php page User will automatically redirect to user.php page. Any idea and sample code for it ?? please help me out thanx in advance Quote Link to comment https://forums.phpfreaks.com/topic/74214-solved-different-page-for-different-user-after-login/ Share on other sites More sharing options...
darkfreaks Posted October 21, 2007 Share Posted October 21, 2007 <?php if ($_SESSION[loggedin]=="true"){ header("Location: user.php");} elseif ($_SESSION[loggedin]=="true"||$usertype=="admin"){ header("Location: admin.php");}?> Quote Link to comment https://forums.phpfreaks.com/topic/74214-solved-different-page-for-different-user-after-login/#findComment-374849 Share on other sites More sharing options...
Daniel0 Posted October 21, 2007 Share Posted October 21, 2007 <?php if ($_SESSION[loggedin]=="true"){ header("Location: user.php");} elseif ($_SESSION[loggedin]=="true"||$usertype=="admin"){ header("Location: admin.php");}?> It should be 'loggedin' and not loggedin unless you have a constant named loggedin. See: http://www.php.net/manual/en/language.types.array.php#language.types.array.foo-bar Quote Link to comment https://forums.phpfreaks.com/topic/74214-solved-different-page-for-different-user-after-login/#findComment-374858 Share on other sites More sharing options...
black_box Posted October 21, 2007 Author Share Posted October 21, 2007 Thnx to all for helping me i will try this code and let u knw its working or not ..thanx again i m so pleased to be here Quote Link to comment https://forums.phpfreaks.com/topic/74214-solved-different-page-for-different-user-after-login/#findComment-374873 Share on other sites More sharing options...
black_box Posted October 21, 2007 Author Share Posted October 21, 2007 I m really sorry to inform u that i m new in this PHP .. I made a database those columns are: id, name, pass & user right when they give the id and pass then the database will compare them and redirect to the desired page. any code for it ?? do i need cookie for it?? Quote Link to comment https://forums.phpfreaks.com/topic/74214-solved-different-page-for-different-user-after-login/#findComment-374879 Share on other sites More sharing options...
maxrubino Posted April 21, 2009 Share Posted April 21, 2009 Yes, it works! Easy and safe too. But... Imagine 2 user: admin/password and Mister/password2 If I log in like (example) admin/password and I will be redirect to admin.php, then I will have free access to the page Mister.php (if I know it)! How can I do to limit admin to stay in admin pages and Mister to surf only Mister pages? Thank you... Quote Link to comment https://forums.phpfreaks.com/topic/74214-solved-different-page-for-different-user-after-login/#findComment-815564 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.