I’m trying to implement a role-based access model (RBAC) which I got from https://sevvlor.com/post/2014/10/14/how-to-make-role-based-access-control-in-php/.
I’m getting 3 errors and I was unable to fix them.
This is my first time ever working with CLASS.
Strict Standards: Accessing static property User::$db as non static in C:\...\user.class.php on line 16
Notice: Undefined property: User::$db in C:\...\user.class.php on line 16
Fatal error: Call to a member function prepare() on a non-object in C:\...\user.class.php on line 16
This is how it should be used…
[php]session_start();
//Connect to the database etc…
include("…/protected/connect_db.php");
require_once “Role.class.php”;
require_once “User.class.php”;
$user = new User($_SESSION[“user_id”]);
if ($user->hasPermission(“permission”)){
//This user is allowed to do this
echo “Great, this user has permission to do this”;
}[/php]