CodeIgniter Forums
route system - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: route system (/thread-66046.html)



route system - kh8b8r - 08-28-2016

i want to route like this

ex: 

http://localhost/index.php/user/USERNAME_FROM_MYSQL



PHP Code:
class Host extends CI_Controller {


public function ?()
{

}




RE: route system - cartalot - 08-29-2016

PHP Code:
public function readTheTutorial()
{
    
// your awesome code will go here


http://www.codeigniter.com/user_guide/tutorial/index.html


RE: route system - dmyers - 08-29-2016

(08-28-2016, 11:22 AM)kh8b8r Wrote: i want to route like this

ex: 

http://localhost/index.php/user/USERNAME_FROM_MYSQL



PHP Code:
class Host extends CI_Controller {


public function ?()
{

}


You probably want something like this:

http://www.codeigniter.com/user_guide/general/controllers.html?highlight=remap#remapping-method-calls

PHP Code:
class user extends CI_Controller {

 
 public function _remap($user) {
    /* validate $user here */
 
   $this->do_something_with($user);
 
 }



DMyers


RE: route system - InsiteFX - 08-29-2016

PHP Code:
// ./application/config/routes.php

$route['default_controller'] = 'welcome';

$route['(.*)'] = 'welcome/index/$1';

// ------------------------------------------------------------------------

class Welcome extends CI_Controller
{
 
   /**
     * index ()
     * --------------------------------------------------------------------
     * 
     * index - default method called.
     *
     */
 
    public function index($user NULL)
 
   {
 
        if ( ! empty($user))
 
       {

 
       }
 
       else
        
{

 
       }
 
   }


 
   /**
     * _remap()
     * --------------------------------------------------------------------
     *
     * Remaps the URL segments.
     *
     * @param   string
     * @param   array
     * @return  mixed
     */
 
    public function _remap($method$params = array())
 
    {
 
        if (method_exists($this$method))
 
        {
 
            return call_user_func_array(array($this$method), $params);
 
        }

 
        show_404();
 
   }





RE: route system - Joel Catantan - 08-29-2016

(08-28-2016, 11:22 AM)kh8b8r Wrote: i want to route like this

ex: 

http://localhost/index.php/user/USERNAME_FROM_MYSQL



PHP Code:
class Host extends CI_Controller {


public function ?()
{

}



routes.php

PHP Code:
$route['user/(:any)'] = 'user/get/$1'

Controller: User.php

PHP Code:
class User extends CI_Controller
{
    
function get($username)
 
   {
        .. some codes ..
 
   }


CHEERS~!