mysql - PHP - Restrict access to admin page for logged on user -
i have table in database users, each user has auth_level (1-3). on site have admin page adding/deleting new user accounts, want restrict access page users have auth level of 3. have been trying work sessions stuck. hoping can me out.
here code restricting access. not sure have gone wrong. check.php start session.
<?php require_once('check.php'); //this function returns true if auth level = '3' //otherwise returns false function checkaccess() { $result = (isset($_session['sess_auth_level']) && $_session['sess_auth_level'] == 3 ); if(!$result) { header('www-authenticate: basic realm=“test restricted area”'); header('http/1.0 401 unauthorized'); return false; } else { header("location: admin.php"); } } ?> if log in user auth level 1 or 3, same blank page.
i think never call checkaccess(). calling maybe fixes error.
Comments
Post a Comment