change any rule in codeigniter to match function -


i have set routes.php suit nature of site. unfortunately, there problem last route i.e.:

$route['(:any)']     = "profile/profile_guest/$1"; 

if username password name passed correct, e.g. domain.com/username, load his/her data. if not, loads page errors (because failure retrieve data non-existent user in database). problem! want avoid error showing.

is there anyway avoid error happening? none of echoes seems printing or redirect neither working. don't know why! if code inside method not executing , view loaded instead. below part of profile_guest function:

public function profile_guest($username)     {             $username = $this->uri->segment(1);             //echo "hello " . $username;                 redirect('main', 'refresh');             if($username != '')             {                 /* echo "<h1>hello world something</h1>"; */ 

it's hard without seeing rest of code.

maybe need check value before running query:

// user_model function get_user($username = null){     if($username){         return $this->db->query(...     }else{         return false;     } } 

then check query returned before loading view

if($this->user_model->get_user($username){     //show page }else{     echo "no user found"; } 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -