Welcome Guest, Not a member yet? Register   Sign In
route system
#1
Brick 

i want to route like this

ex: 

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



PHP Code:
class Host extends CI_Controller {


public function ?()
{

}

Reply
#2

(This post was last modified: 08-29-2016, 11:29 AM by cartalot.)

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


http://www.codeigniter.com/user_guide/tu...index.html
Reply
#3

(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/ge...thod-calls

PHP Code:
class user extends CI_Controller {

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



DMyers
Reply
#4

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();
 
   }


What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(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~!
[Just a programmer] Cool [/Just a programmer]
Reply




Theme © iAndrew 2016 - Forum software by © MyBB