Sandi Budic Sandi Budic - 2 months ago 15
MySQL Question

user and superuser permissions

i just google one hour and i didnt find anything. i wanna try here...
Is possible in php to create something like admin permission on

button
?
i have login and users in MySQL.
so my question is... can i put on my "download"
button
permission to only admin can access it? (only admin can download
excel
table with some information)
sorry for my bad English.enter image description here

Answer

STEP-1: When you validate user login successfully, assign some flag like $_SESSION['flag'] = "user";. And do the same for admin like: $_SESSION['flag'] = "admin";

<?php
   ob_start();
   session_start();
   ......
   // login successful, then assign session 
   $_SESSION['flag'] = "admin";   
   // or for normal user
   $_SESSION['flag'] = "user";

STEP-2: Use this session variable to identify is user is admin or normal user and show or hide the download button like:

<?php 
  ob_start();
  session_start();

  if(isset($_SESSION['flag']) && !empty($_SESSION['flag']) && $_SESSION['flag']=="admin"){
       // code here for admin - show download button as you want!
       echo "<button id='btn_download'> Download </button>";
  } // else { // code here for normal user }

?>
Comments