0

I need help where every page I give value 1 so what I want if page without value 1 cannot be access with another user

my logic like this :

<li class="treeview">
  <a href="#">
    <i class="fa fa-gears"></i> <span>User Setting</span> <i class="fa fa-angle-left pull-right"></i>
  </a>
  <ul class="treeview-menu">
    <li><a href="<?= $this->config->base_url() ?>changepassword?f=1"><i class="fa fa-circle-o"></i> Change Password</a></li>
    <li><a href="<?= $this->config->base_url() ?>infouser"><i class="fa fa-circle-o"></i> Info User</a></li>
  </ul>
</li>

if user B who don't have access want to open page changepassword.php disable because in database access they don't have value 1 but 0.

but they can open page infouser.php cause value not 1

there any one can give me logic using codeigniter where my database like this :

no | UID     | PWD               |  access |
1  | user A  | user A            |  11     |
2  | user B  | user B            |  10     |
2
  • Please edit and refine this part of your question, *where every page i give value 1 so what i want if page without value 1 cannot be access * Commented Feb 13, 2017 at 4:26
  • Are you trying to do 'group' access (like access levels) or specific users can only access specific places and its on a user, by user or a 1:1 basis? Commented Feb 13, 2017 at 10:53

1 Answer 1

1

Well, you need to create ACL Functionality.

in which you need to create a pivot table.

id (int) 11
user_id (int) 11
controller (text)
action (text)

Database Records can be :

| 1 | 3 | users | dashboard |
| 1 | 3 | users | profile |
| 1 | 3 | users | password |

and you can make an interface to update user with their allowed controllers/actions

In this way, you can allow users to access their respective actions.

To get the permissions, you need to run the query with current user id and get controller/action from URL or getRoutes function.

Sign up to request clarification or add additional context in comments.

6 Comments

Hi Naveed, thanks for help but what logic between column access?
its mean if i have 5 pages for administrator every page i gave value 1 where in the database looks like '11111'
Hi Naveed, its mean i have to add 1 column for menu so i can put dashboard, profile and password? cause i think just need explode() code to spare my column access where there '11111' its mean in array Array ( [0] => 1 [1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 1 ) where every page i think i give like localhost/user?access=1 so for admin can access but for another user without access 1 they cannot access but i need help for logic cooding
It maybe work fine but what if new page has been added and sequence will be changed ?
im not sure about that i just need some sample code
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.