They will all need an access level in the database eg 1 for client 2 for manager 4 for supervisor.
then its just a case of checking it when writing the form.
eg
for future scripts you can put these in any of your included files:
PHP Code:
function check_access($x) {
if ((strpos($_SESSION['access_level'], $x)) !== false){
$allgood = true;
}
return $allgood;
}
function breakdown_access($x) {
$n = 1 ;
$allow ='-';
while ( $x > 0 ) {
if ( $x & 1 == 1 ) {
$allow .= $n.'-';
}
$n *= 2 ;
$x >>= 1 ;
}
return $allow;
}
and they are used as so:
on the create/edit user forms have 3 checkboxes with these names
Code:
Client : <input name='UserLVL_1' type='checkbox' id='UserLVL_1' value='1' />
Manager : <input name='UserLVL_2' type='checkbox' id='UserLVL_2' value='2' />
Supervisor : <input name='UserLVL_4' type='checkbox' id='UserLVL_4' value='4' />
and add them together when updating / inserting a user/client
PHP Code:
$U_Level = ($_METHOD['UserLVL_1'] + $_METHOD['UserLVL_2'] + $_METHOD['UserLVL_4']);
when logging in you can break down the stored access level:
PHP Code:
$_SESSION['access_level'] = breakdown_access($row['AccessLevel']);
on your complaint form page you check the access level like this:
add the access level numbers together from C=1 M=2 S=4
PHP Code:
if (check_access('1') == 1){
//form only clients can see if managers and supervisors can also see it change above to 7
}
if (check_access('2') == 1){
//manager only comment form
}
if (check_access('4') == 1){
//supervisor only comment form
}
if (check_access('6') == 1){
//manager or supervisor comment form
}