Please how can I hide a form or input field based on the user role or privilege using PHP. is it possible to do that using sessions and if so, how?
Advertisement
Answer
function return_html(){ $role = $_SESSION['role']; $approved_role=[1,2]; if(in_array($role ,$approved_role)){ echo '<button>Add New</button>'; } }
use this function in your form it will be global and you can also defined permission in your db and fetch it inside the function and then make the condition.