Advertisement
michaelyuen

Untitled

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