How to implement different permissions to enter different pages in PHP
First, when the user logs in successfully, add the user's permission level to the Session session ;
<?php $user_perm_level = 1; session_start(); $_SESSION['user_perm_level'] = $user_perm_level; ?>
Then when accessing the page, take out the permission level stored in the Session;
<?php session_start(); $user_perm_level = $_SESSION['user_perm_level']; ?>
Finally, jump to the corresponding page according to the permission level.
<?php session_start(); $user_perm_level = $_SESSION['user_perm_level']; switch($user_perm_level){ case 1: header("location: topage1.php"); break; case 2: header("location: topage2.php"); break; case 3: header("location: topage3.php"); break; default: header("location: topage.php"); break; } ?>
Recommended tutorial: "PHP Tutorial"
The above is the detailed content of How to implement different permissions to enter different pages in PHP. For more information, please follow other related articles on the PHP Chinese website!