Như các bạn đã biết ,sau khi đăng nhập xong thì ta cần phân quyền giữa Admin và user để điều hướng đúng đến trang quản trị(Admin) hoặc user, ta sẽ phân quyền dựa trên giá trị 0 và 1 trong bảng CSDL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
case 'layquyen': //echo "session la:".$_SESSION['username']; //echo "<br>session password:".$_SESSION['password']; if (isset($_SESSION['username'])&&isset($_SESSION['password'])) { # code... //TA SE TAN DUNG SESSION SAU KHI DA LUU GIA TRI XONG, TA SE GAN CHO BIEN //TU BIEN-->VAO MODEL DE XU LY ,lay DL theo username va PASS-->In ra $username=$_SESSION['username']; $pass=$_SESSION['password']; echo($username); echo "<br>"; echo($pass); $user=Database::GetDataUSER("cauthu",$username,$pass); //echo "<br>quyền là:".$user->quyen ; //sau khi lay dc TT user thanh cong,ta se gan gia tri cho SESSION[quyen]; $_SESSION['quyen']=$user->quyen ; //echo "<br>quyền cua ban là:".$_SESSION['quyen'] ; if ($_SESSION['quyen']==1) { header('location:index.php?controller=cauthu&action=list'); } if ($_SESSION['quyen']==0) { header('location:index.php?controller=cauthu&action=Thongtinuser'); } } else { header("location: http://localhost/hocphp/Baocao/QLCLB/index.php?controller=cauthu&action=dangnhap"); } //require_once("view/infor.php"); break; |