Question: I am building an entire system using PHP and MySQL.

I want to create usergroups.

For example
I want *ADMIN1* to be able to **ADD USER**, and **REMOVE USER**

BUT

I want *ADMIN2* to be able to **ADD USER** only

What is the standard way to do this?

Thanks.

Answer: 
You could use a simple login system and use sessions to allow access to certain pages e.g.

```
session_start();
if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) {
header ("Location: login.php");
}

```

This example just stops the user from accessing any other pages without first logging in. The login page would change the session like so:

```
        if (!empty ($username) && !empty ($password)){
        $sql = mysql_query ("SELECT * FROM users WHERE username='".$username."' AND password ='".$password."' LIMIT 1");
        if (mysql_num_rows ($sql) > 0){
            $_SESSION['login']=1;
            $_SESSION['username']=$username;
            header ("Location: index.php");
        }

```

That's just a basic example but hopefully you can see what can be done using a user's table and sessions :)
There aren't *usergroups* in mysql. You'll need to use the grant syntax: <https://dev.mysql.com/doc/refman/5.5/en/grant.html>