-2

i will make a project management web app. if the user register the system will give a URL.

www.site.com/company_name

how should i do it when he user used this url it will also check in the database if it exist?

in codeigniter the format should be

www.site.com/controller/function
The Alpha
  • 143,660
  • 29
  • 287
  • 307

1 Answers1

3

If this is about Routing then you may create a Controller i.e. Profile to retrieve the user according to company_name passed in to the url, in this case you may route it like

// application/config/routes.php
$route['(:any)'] = 'profile/get_user/$1';

In this case, when a url like www.site.com/microsoft is given, this will be routed to Profile controller and will call the get_user method and microsoft will be passed to the method as it's parameter. So, your controller should look something like this

class Profile extends CI_Controller {

    public function get_user($company_name = null)
    {
        // Check if $company_name exists or not and do something with it
        // Query for the user in the appropriate table
        // and search using $company_name (make sure this field is unique)
    }
}

Also, you can use a route like this

$route['([a-zA-Z0-9]+)'] = "profile/get_user/$1";

Also, remember, a url with www.site.com/john could also be routed to profile/get_user/john instead of User/show/john if you have a controller/method like this. Read more on URI Routing.

The Alpha
  • 143,660
  • 29
  • 287
  • 307