0

Codeigniter 및 Tank Auth를 사용하고 있으며 Ubuntu OS를 사용하고 있습니다. 내 IP를 사용하여 프로젝트에 액세스하면 다음과 같이 표시됩니다.Codeigniter - URL에 입력 한 사용자 이름을 사용하여 프로필 검색

http://192.168.1.10/project/auth/login 

URL을 사용하여 프로필을 검색하는 기능을 구현해야합니다. 입력하면 가정합니다.

http://192.168.1.10/project/vishmay 

그런 다음 내 프로필이 표시되어야합니다. 아무도 그것을 어떻게 할 수 말해 줄래?

내가 시도 내 routes.php에

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/'); 
     } 
    } 
+0

당신이 $ this-> uri-> 세그먼트에서 사용자 이름을 얻고있다 (1); –

+0

아니요, 나는 그것을 반향했지만 사용자 이름을 인쇄하지 않고'http : // 192.168.1.10/project/vishmay'와 같은 URL을 입력하면됩니다. 그것은 완전히 빈 페이지를 표시합니다. – V15HM4Y

답변

2

같은 auth.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'; 

도 만든 인덱스를()이 일을 당신은 변경해야합니다 :

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

~

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

$1 세그먼트 값을 올바르게 가져올 수 있습니다.

그리고 당신은이 코드를 시도 할 수 있습니다 :

을보십시오이 :

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/'); 
    } 
} 
+0

여전히 같은 결과이지만 모델 내부로 들어가는 것은 아닙니다. – V15HM4Y

+0

@VishmayPatel 내 게시물을 업데이트 – pktangyue

+0

죄송합니다. 작동하지 않습니다. – V15HM4Y