我有一个登录数据库
username | password | role
xxxxxx xxxxxxx Admin
xxxxxx xxxxxxx Trainer
xxxxxx xxxxxxx Client
xxxxxx xxxxxxx Line Manager
Run Code Online (Sandbox Code Playgroud)
是否可以在登录时将具有管理员角色的人重定向到admin.php具有培训师角色的人登录到trainer.php具有客户角色的人登录到client.php.
假设您已经从数据库中检索了用户信息,并将其角色存储到Session变量中,它就像这样简单......
<?php
session_start();
$role = $_SESSION['role'];
if($role=="Admin"){header("location: www.yourpage.com/admin.php");}
elseif($role=="Trainer"){header("location: www.yourpage.com/trainer.php");}
elseif($role=="Client"){header("location: www.yourpage.com/client.php");}
Run Code Online (Sandbox Code Playgroud)