I have an index page, where you go to when you log in. Each account has an account level, for example '1' and '2'. I want the account with level 1 to see an 'Edit' button and a 'Delete' button. I want the account with level 2 to see an 'Connect' button and an 'Inspect' button.
What's the best way to do this? I have this in my login code, which, if I'm right, gets the account level from the database.
$_SESSION['type'] = $type;
As you are storing a session named "type" that will define the type of user which is logged in right now.
So, on your index.php page, you can add the following conditions on base of which you can show your desired buttons.
<?php
if ($_SESSION['type'] == 1)
{
?>
<button>Edit</button>
<?php
}
else if ($_SESSION['type'] == 2)
{
?>
<button>Delete</button>
<?php
}
else
{
?>
<button>Other</button>
<?php
}
?>
You can update this sample code according to your needs and requirements.