I am always short of logic when every things works fine then i come up with new problem?

PROBLEM There are generally 6 user type accounts.Everyone has their own "edit profile page".Now i want to know how can i handle this.user login then directed to home page then in navbar it has option edit profile etc. how can i load a edit profile view for crosponding user type.like if user type 1 login then load edit profile page for user type 1,if user type 2 login then edit profile page for user type 2 is loaded? I am using codeigniter framework?plz help

Update profile controller

public function get_user_data() {
if($this->session->userdata['sessiondata']['user_id'] !=null) {
$id=$this->session->userdata['sessiondata']['user_id'];
$data['countryDrop'] = $this->Country_states_cities->getCountries();  
$result=$this->Edit_profile->get_user_data($id);
$result=$result[0];
$this->load->view('header');
$this->load->view('edit_profile', array_merge($data,$result));
} 
else {

            redirect(base_url("HomeController/index"));      
     }  

}

/*  
  Function for updating user data 
**/

......

in header view i set this

if user login

<li><a title="Set profile picture and update info" href="<?php echo base_url('Update_profile/get_user_data') ?>">Edit Profile</a></li>

you can see if user is login then above controller is called and edit profile will be loaded now i want diiferent edit profile page to be loaded depending upon user type?

So i have problem in thinking and implementing the logic!!plz help

I'm assuming the user's have their roles stored in the database and you extract them out when the user logs in successfully. Once you have that stored in the session (or wherever you keep it).
Then you have options. If the edit profile pages are quite different you can create the required templates and use a switch statement to recirect to the correct one based on the role.
Or, you can have one template with all of the controls needed, and when it is loaded only the relevant options for each role get displayed.
The same logic can work for adding links to menus, etc.

commented: ah thnks this solved my problem +0

is this approach right

if ($this->session->userdata['sessiondata']['user_id'] != null) {
            $id                  = $this->session->userdata['sessiondata']['user_id'];
            $user_type           = $this->session->userdata['sessiondata']['user_type'];
            $data['countryDrop'] = $this->Country_states_cities->getCountries();
            if ($user_type == 1) {
            //load view one 
            } elseif($user_type == 2){
            //load view 2

            }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.