[eluser]tommizzle[/eluser]
Hi all,
I have just started using CI about 2 days ago, and have come into a problem with the _remap function. I'm trying to redirect anything off the 'www.root.com/username' to 'www.root.com/profile/username', and have no idea where I'm going wrong - Any help will be appreciated.
Controller:
Code:
<?php
class Home extends Controller {
function _remap($username)
{
$this->load->model('Home_model');
$is_user = $this->Home_model->is_valid_user($username);
echo $is_user;
if($is_user == true):
header('Location: /profile/' . $username);
exit;
else:
$data = array();
$data['lastjoined'] = $this->Home_model->get_last_joined(3);
$data['representing'] = $this->Autoload_model->get_socialnetworks('random',10);
$data['randomtip'] = $this->Autoload_model->get_random_tip();
$data['latestnews'] = $this->Autoload_model->get_latest_news(3,50);
$this->load->view('header');
$this->load->view('home',$data);
$this->load->view('footer');
endif;
}
}
Model:
Code:
<?php
class Home_model extends Model {
function get_last_joined($limit = '10')
{
$this->db->select('*');
$this->db->from('user');
$this->db->join('country', 'user.country_id = country.id');
$this->db->limit($limit);
$query = $this->db->get();
return $query->result();
}
function is_valid_user($username = '')
{
$this->db->select('id');
$this->db->from('user');
$this->db->where('user_name', $username);
$this->db->limit(1);
if($this->db->count_all_results() < 1):
return false;
else:
return true;
endif;
}
}
Apologies for the crappy code ;p