Codeigniter - Search profile using username entered in URL -
i using codeigniter , tank auth , using ubuntu os. when access project using ip, comes like:
http://192.168.1.10/project/auth/login
i have implement functionality of searching profile using url. suppose if come in
http://192.168.1.10/project/vishmay
then should show profile. can tell me how it?
i have tried doing in routes.php
$route['default_controller'] = "welcome"; $route['auth/login'] = 'auth/login'; $route['auth/register'] = 'auth/register'; $route['auth/logout'] = 'auth/logout'; $route['welcome/profile'] = 'welcome/profile'; $route[':any'] = 'auth/index/$1';
and made index() in auth.php controller like
function index() { $username=$this->uri->segment(1); $data['result']=$this->users->get_profile_pic1($username); if ($message = $this->session->flashdata('message')) { $data['reg_success'] = "you have been registered successfully."; $reg_success = 1; redirect('/auth/register', $data); } else { redirect('/auth/login/'); } }
you should change:
$route[':any'] = 'auth/index/$1';
to
$route['(:any)'] = 'auth/index/$1';
to create $1
can correctly segment value.
and can seek code:
try this:
function index($username = '') { $data['result']=$this->users->get_profile_pic1($username); if ($message = $this->session->flashdata('message')) { $data['reg_success'] = "you have been registered successfully."; $reg_success = 1; redirect('/auth/register', $data); } else { redirect('/auth/login/'); } }
codeigniter codeigniter-url tankauth codeigniter-routing
No comments:
Post a Comment