2 Replies - 641 Views - Last Post: 31 October 2011 - 05:05 PM Rate Topic: -----

#1 [email protected]  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 02-September 11

Grant admin privileges to another user.

Posted 31 October 2011 - 04:03 AM

In my site i wanted to give admin previledges to another user.In the database i use Type coloumn for the Registered user check Admin or Not... Maintain a bit.(If admin Type coloumn is 1 & if Normal user Type coloumn is 2 ).Anyone give a idea how to do this.

I have several registered users.I wanted to search some user and give a admin previledges to that user.Actually need to Change type coloumn 2 to 1.

How can i do this ?
Is This A Good Question/Topic? 0
  • +

Replies To: Grant admin privileges to another user.

#2 Duckington  Icon User is offline

  • D.I.C Addict

Reputation: 172
  • View blog
  • Posts: 614
  • Joined: 12-October 09

Re: Grant admin privileges to another user.

Posted 31 October 2011 - 04:23 AM

Just UPDATE that row and change the field "Admin" to value "1" instead of "2", or however you are doing it.
Was This Post Helpful? 1
  • +
  • -

#3 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 962
  • View blog
  • Posts: 2,380
  • Joined: 15-February 11

Re: Grant admin privileges to another user.

Posted 31 October 2011 - 05:05 PM

That's the simplest way of doing it. Personally I'd suggest implementing User Groups for a small web application. The advantage of this is you have a lot more flexibility as opposed to just identifying a user as an Admin or not.

A simple user group consists of the group's name, power and ID. You may want to set the maximum power to 100 which symbolizes the Administrator group. However else you decided to spread the other 99 numbers is up to you. With this method you can restrict a certain page or action to only users with a power greater than a certain value. For instance if you want to limit a page to only Administrators (100) and Moderators (80) you'd use an IF statement for the comparison.
if($user->power >= 80)
    //don't allow

The table structure within the database is also very simple. The most required to implement this are two tables, User Group and User Account. Your User Account table however must have a foreign key pointing to User Group.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1