Advertisement
michaelyuen

Untitled

Dec 25th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. <?php
  2. /* page access */
  3.  
  4. $page_access = ['admin','reseller'];
  5. if (!in_array($_SESSION['user_role'], $page_access)) {
  6. // $user cannot access this page, I should give warning or redirect to somewhere else
  7. // die('Error: Unauthorized Access');
  8. }
  9.  
  10. /* data access */
  11.  
  12. function get($data_id) {
  13. if ($_SESSION['user_role'] == 'admin') {
  14. $sql = "SELECT * FROM 'table' WHERE `data_id` = {$data_id}";
  15. }
  16. if ($_SESSION['user_role'] == 'user') {
  17. $sql = "SELECT * FROM 'table' WHERE `username` = '" . $_SESSION['username'] . "' AND `data_id` = {$data_id}";
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement