Site Cloner PHP Script
Bargain Hunter PHP Script
Job Hunter PHP Script
Site Login and Access Control PHP Script

PHP user Access

There could be times when you need to create user access levels for php / mysql scripts. The simplest method is to create a table column that can hold specific access levels such as 1, 2 , 3.  1 could be public, 2 could be registered users and 3 could be administrators.

Here is a block of code which shows 3 different user levels and how to output code blocks based on that output level.

<?php session_start();
//echo $_SESSION[‘session_name’];
//set a variable to the session name
$user = $_SESSION[‘session_name’];

if ($user) {
//select statement to find access level based on unique username

$command=”SELECT table.ID, table.Username, table.access_level from table WHERE table.Username=’$user’;”;
$result = mysqli_query($db, $command);
if ($result && mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)) {
//echo $row[‘Username’];
//echo $row[‘access_level’];

if ($row[‘access_level’]==’1′) {
//add custom content here for this user access level?>

<?php }

else if ($row[‘access_level’]==0){
//add custom content here for this user access level

} else {
//add custom content here for public access level
<?php }?>