title: PHP code to restrict member access by permissions
body: <p>I am building a website in PHP &amp; mySQL. It has frontend and backend capabilities. Only admin can enter the backend by means of username and password. Now if the admin wants to add other sub-admins to the website, he could do so. By this method, a sub-admin will be able to login and perform all actions that the original admin is able to do.</p>
  
  <p><strong>WHAT I WANT TO DO:</strong></p>
  
  <p>I want  to restrict the access of the sub-admins at my choice and assign them permissions so that they are able to access only certain portions of the admin panel. </p>
  
  <p><strong>EXAMPLE OF THE FEATURE THAT I AM TALKING ABOUT:</strong></p>
  
  <p>Consider that I have the following links accessible by original admin.
  1. Add articles 2. Approve articles 3. Delete Articles 4. Add User 5. Edit user 6. Delete User 7. Change site settings 8. View Financial info 9. Mail center</p>
  
  <p>If I do not set any permissions, then all sub-admins will be able to access all of above links. Say I create 2 sub-admins 'David' and 'Bob'. </p>
  
  <p>Now I want David to access only the following desired sections of the backend:</p>
  
  <ol>
  <li>Add articles, 4. Add User,  7. Change site settings</li>
  </ol>
  
  <p>Now I want Bob to access only the following desired sections of the backend:</p>
  
  <ol>
  <li>Add articles, 2. Approve articles, 3. Delete Articles, 4. Add User, 9. Mail center</li>
  </ol>
  
  <p>I, being the original admin, should be able to access all sections whereas, David and Bob, should be able to see &amp; access only the links and pages (or functionality) that have been assigned to them. I don't have a clue as to how to do this. Also, for example, if I want to restrict a sub-admin to access only 'Add articles' page, then  I also want him to access the page that it posts to (considering that the input is on Add articles page)  add_articles_next.php page. Also note that 'add_articles_next.php page' does not appear anywhere in the list of links. It is merely a page that is posted to from the page to which the sub-admin has access.</p>
  
  <p>I understand that there is no way for the system to know that unless I explicitly specify it, but yes, that's my question. How to do it? I am not a object oriented person, so PHP code using functions will be great for me.</p>
  
  <p><strong>OTHER LIVE EXAMPLES OF THE FEATURE THAT I AM TALKING ABOUT:</strong></p>
  
  <p>I came across a feature while researching this topic. <a href="http://drupal.org/project/views_bulk_operations" rel="nofollow noreferrer">Click here to visit it</a>. This looks like somewhat similar feature.</p>
  
  <p>Thank you all in advance for any code that you can give me.</p>