Before we start, I'm a beginner. I'm sure it's a simple solution but just not for me.
I'm using a session so no one can't access an admin page unless they're an admin.
The code is:
- if ( $_SESSION['admin'] != 1 ) {
- $_SESSION['message'] = "You're not admin!";
- header("location: ../error.php");
- }
Which works perfectly. regular users can't access it but admins can. BUT.
In my main cpanel I want to have a button linking to the admin panel that will only appear if the user is admin. I did the same piece of code:
- if ( $_SESSION['admin'] != 1 ) {
- echo '<a href="admin/index.php"><button class="butto button-bloc" name="admin"/>Admin Panel</button></a>';
- }
Problem is, it seems like the button shows up whether the user is an admin or not and now I think that my code is just trying to make me blow my lid as I spent a full hour trying to find what the f-- is on the go.
Any help would be greatly appreciated! I'm sure someone who's good with PHP will have it solved in under a minute lol