how to get a passed data from the url in codeigniter -


hi have data passed in url http://www.test.com/dashboard/john-doe

i want page when enter http://www.test.com/dashboard/john-doe john doe name database retrieve when users can login.

so dashboard controller how able page if passed data john-doe next dashboard controller? can me figured thing out? muchly appreicated controller below

<?php if ( ! defined('basepath')) exit('no direct script access allowed');  class dashboard extends ci_controller {   public function __construct(){     parent::__construct();         $this->load->model('users_model', 'um');          $sessiondata = $this->session->userdata('loggedin');         $this->data['id'] = $sessiondata['userid'];          if(!$this->session->userdata('loggedin')){       redirect('login');     }    }      public function index($slug){         echo $slug; exit;         $this->data['title'] = 'dashboard | test';         $this->data['menu'] = 'dashboard';         //get customerinfo         $this->data['getcustomerinfo'] = $this->um->getcustomerinfo($this->data['id']);           $this->template_lib->set_view('templatelogin', 'dashboard', $this->data,'',$this->data);     } } 

the index function loaded default if second segment of uri empty. if have parameters need define route:

$route['dashboard/(:any)'] = "dashboard/index/$1"; 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -