PHP Tutorials: Register & Login (Part 21): More Account Permissions




Want more? Explore the library at https://www.codecourse.com/lessons Official site https://www.codecourse.com Twitter https://twitter.com/teamcodecourse.

Original source


17 responses to “PHP Tutorials: Register & Login (Part 21): More Account Permissions”

  1. Notice: Undefined variable: session_user_id in index.php is happening because the user is not logged in. In order to solve this, we only need to wrap Alex code with this if (logged_in()) { //alex code } where logged_in is a function that we (or Alex) created to check if the user has logged in or not.

  2. A better way to have access protection is in the "has_access" function to return the value of the user's type like this"mysql_result(mysql_query("SELECT `user_type` FROM `users` WHERE `user_id` = $user_id"), 0);"
    And then checking for the access level like this: "if(has_access($user_data['user_id']) < 4)" this will check against everyone with a lower access key then 4, i.e. 1,2&3

    My usertype setup:
    1 – normal
    2- vip
    3 – op
    4 – admin

    eg. anyone lower than 4 isn't admin…

  3. Lập trình web là một môn học rất hay và cũng rất cần thiết đối với các doanh nghiệp cũng như cá nhân trong thời kỳ công nghệ thông tin đang phát triển như ngày nay.
    Để trở thành một lập trình web chuyên nghiệp. Hãy đến với Athena.
    Để hiểu rõ hơn về môn học này bạn hãy truy cập vào athena.edu.vn
    Hoặc liên hệ: 92 nguyễn đình chiểu, p.đakao, q.1, tp.hcm
    Tel: (08) 2210 3801 – 0943 23 00 99

  4. Hey man, just want to thank you. You have helped me A LOT in the past two days. I have a uni assignment due in 15 hours and if it werent for your easy to understand and in depth tutorials I would have done fuck all and had a higher chance of failing this web application class. (lets hope i dont fail now lol)
    I dont have any money but when I do i will surely send you a fair amount. Thank you so much! I love you (no homo)

  5. table users has an a_gtype column
    table groups has all the premissions with an id
    then simple get the acess type with a query for currect user
    groups looks like this:
    ID, NAME, CADD, CDEL, CMOD etc..and CSEE with tinyint or bool
    if i have request the type for a post news then i call it:
    if(canAccess($_SESSION['userid'],'CADD')){
    // show the form or something
    }
    can acess gets the user from an array ( all user details is stored )
    and query to he is able to do that
    thats the basic

  6. keep goin, but there is a more flexible premission system 🙂
    but i solved this problem with an another table which can be modified by a default admin, and set premissions for different groups. ( or add a new group ) but this is great 😉

Leave a Reply