Giving different web users (admin, customer) different menu views for creating a new account

I have a website with two levels of access, Administrator and Customer. When creating a new account, I want the admin to see the option for making another admin or a customer. I want the customer to only see the customer option. I'm using PHP. Here's what I've tried:

 <?php
 foreach ($types as $type) {
    if (!isset($_SESSION['user_id'])) { //Anyone on the web can see
        echo "<option value=\"" . $type['Customer'] . "\">". $type['Customer'] . "</option>\n";
    }
    else 
    {
        if ($is_admin) { //Only admin can see this option
            echo "<option value=\"" . $type['user_type_id']. "\">" . $type['type_name'] . "</option>\n";
        }

    //Only customer can see
        echo "<option value=\"" . $type['Customer']. "\">" . $type['Customer'] ." </option>\n";
    }
}
?>

It's not accomplishing what I had intended. If anyone has a suggestion of what I could try instead, that would be great. Let me know if you want any of my other code to understand the logic better.

Answers


If I understand the question correctly, the admin can see the customer menu too which is wrong. To stop this, you simply forgot to add the "else" case in the second nest.

  <?php
 foreach ($types as $type) {
    if (!isset($_SESSION['user_id'])) { //Anyone on the web can see
        echo "<option value=\"" . $type['Customer'] . "\">". $type['Customer'] . "</option>\n";
    }
    else 
    {
        if ($is_admin) { //Only admin can see this option
            echo "<option value=\"" . $type['user_type_id']. "\">" . $type['type_name'] . "</option>\n";
        } else { // <-- here

    //Only customer can see
        echo "<option value=\"" . $type['Customer']. "\">" . $type['Customer'] ." </option>\n";
       }
    }
}
?>

Need Your Help

jQuery autocomplete multiples w/remote data through Rails

jquery ruby-on-rails jquery-ui autocomplete ruby-on-rails-3.2

I am trying to set up jQuery autocomplete in Rails 3.2.0. I have it working fine if I set up an array in javascript as the data source. My problem is that the search terms will eventually become to...

Gamma Distribution in Boost

c++ boost random gamma-distribution

I'm trying to use the Gamma distribution from boost::math but it looks like it isn't possible to use it with boost::variate_generator. Could someone confirm that? Or is there a way to use it.