If you want the URL to work you need to include the function name
http://localhost/picyou/user/index/fh
If you want to don't want to have index
in the url then you need to look at URI routing
Question
I'm new for CodeIgniter.
My Controller is:
class User extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->helper('form');
$this->load->library('form_validation');
}
public function index($user)
{
if($user != '')
{
if($this->session->userdata('user_id'))
{
echo 'user in';
}
else
{
redirect('/');
}
}
else
{
echo 'wrong page';
}
}
}
1st of all i logged into this site.
If i give url like http://localhost/picyou/user
it show 'wrong page'...
If i give url like http://localhost/picyou/user/fh
it show '404 Error'...
But I need to display "user in".
Help me...
Solution
If you want the URL to work you need to include the function name
http://localhost/picyou/user/index/fh
If you want to don't want to have index
in the url then you need to look at URI routing
OTHER TIPS
localhost/sitename/class/function/ID
In this way you can call any function of the controller with argument. The first segment represents the controller class that should be invoked. The second segment represents the class function, or method, that should be called. The third, and any additional segments, represent the ID and any variables that will be passed to the controller.