User Roles Php Function !
USER ROLES FUNCTIONSfunction errorRep()
{
$error='Un Authorised !';
echo $error;
} //end function errorRep()
function userRole() //PLACE ($uid) for production //testing value only
{
//PLACE QUERY HERE-$result=mysql_query("SELECT id, role FROM users where id=.$uid.");
$role=2; //data result
$id=2; // test only data result //use htacces with this script.
if ($role == 1) {
echo 'Is User
';
echo 'Dashboard';
}
if ($role == 2) {
echo 'Is Editor
';
echo 'Dashboard';
}
if ($role == 3) {
echo 'Is Publisher
';
echo 'Dashboard';
}
if ($role == 4 and $id==1) { //advised to add global $admin here
echo 'Is Admin
';
echo 'Admin Panel';
}
if ($role == '') {
echo errorRep();
}
} // end function userRole()
echo userRole(); //for production use echo userRole($uid);
No comments:
Post a Comment