0

I am using Codeigniter and Tank Auth and I am using Ubuntu OS. When I access my project using my IP, it comes something like:

http://192.168.1.10/project/auth/login

I have to implement a functionality of searching a profile using URL. Suppose if I enter

http://192.168.1.10/project/vishmay

Then it should show my profile. Can anyone tell me how to do it?

I have tried doing this in my 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 also 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/');
        }
    }
pktangyue
  • 8,326
  • 9
  • 48
  • 71
V15HM4Y
  • 1,757
  • 4
  • 26
  • 40

1 Answers1

2

You should change:

$route[':any'] = 'auth/index/$1';

to

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

to make the $1 can correctly get the segment value.

And you can try this 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/');
    }
}
pktangyue
  • 8,326
  • 9
  • 48
  • 71