alvin567 Posted July 13, 2012 Share Posted July 13, 2012 http://forums.phpfreaks.com/index.php?topic=362350.new;topicseen#new Hi there,I am trying to write codes for my login functions, grant access rights to different php pages? any algorithms? database settings? setting of flag in the database? Quote Link to comment https://forums.phpfreaks.com/topic/265602-access-rights-to-different-php-pages/ Share on other sites More sharing options...
alvin567 Posted July 13, 2012 Author Share Posted July 13, 2012 example directory- files1 files2 directory2- files1 files2 I am using mysql for my membership database,and php and html for my coding that is all Quote Link to comment https://forums.phpfreaks.com/topic/265602-access-rights-to-different-php-pages/#findComment-1361228 Share on other sites More sharing options...
ignace Posted July 13, 2012 Share Posted July 13, 2012 On top of each page: if (!user_has_access(__FILE__)) { user_forbidden_handle(); } If you use a single point of entry like index.php which routes to a controller/page then write this in your index.php. Quote Link to comment https://forums.phpfreaks.com/topic/265602-access-rights-to-different-php-pages/#findComment-1361231 Share on other sites More sharing options...
alvin567 Posted July 13, 2012 Author Share Posted July 13, 2012 ok,you mean use database to set the rights? Quote Link to comment https://forums.phpfreaks.com/topic/265602-access-rights-to-different-php-pages/#findComment-1361232 Share on other sites More sharing options...
ignace Posted July 13, 2012 Share Posted July 13, 2012 Preferably, yes. How you want to handle wether a user has access to a certain page is up to you to implement in the user_has_access() function. Quote Link to comment https://forums.phpfreaks.com/topic/265602-access-rights-to-different-php-pages/#findComment-1361234 Share on other sites More sharing options...
alvin567 Posted July 13, 2012 Author Share Posted July 13, 2012 if (!user_has_access(__FILE__)) { user_forbidden_handle(); // what does user_forbidden_handle(); means? } Quote Link to comment https://forums.phpfreaks.com/topic/265602-access-rights-to-different-php-pages/#findComment-1361236 Share on other sites More sharing options...
ignace Posted July 13, 2012 Share Posted July 13, 2012 It's supposed to handle when a user tries to access something they are not authorized to. So user_forbidden_handle() should either redirect to or display a not authorized webpage. You can extend this further to also log this in the database so that you can track malicious activity. Quote Link to comment https://forums.phpfreaks.com/topic/265602-access-rights-to-different-php-pages/#findComment-1361240 Share on other sites More sharing options...
alvin567 Posted July 15, 2012 Author Share Posted July 15, 2012 so u mean the user_forbidden_handle() i am suppose to write it myself? Quote Link to comment https://forums.phpfreaks.com/topic/265602-access-rights-to-different-php-pages/#findComment-1361630 Share on other sites More sharing options...
ignace Posted July 15, 2012 Share Posted July 15, 2012 Yes. Same with user_has_access() Quote Link to comment https://forums.phpfreaks.com/topic/265602-access-rights-to-different-php-pages/#findComment-1361634 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.