0

I have been working on codeigniter for past 1 year, but never found this problem, probally because i have been always working with functions with parameters

let me show u the issue

say i have a function like this in my front

class user extends CI_Controller{
    public function __construct() {
        parent::__construct();
        @session_start();
        $this->load->library('encrypt');
    }
    /*------------for registration-------------*/
    function register()
    {
       }

now it will be called like this

http://example.com/user/register

i am passing no arguments in the register function

now if i write like this in the address bar

http://example.com/user/register/abc/abd

then also the register function will be called showing no error

as i am passing two parameters for the register function, and on register function i am not catching them..

i want in such case the 404 error should be shown,, how can i do this...

1
  • Its not an issue with Codeigniter. That's how it is made. By the way most website work like that. I don't know why you want to show 404 instead of just ignoring those parameters. Commented Jul 4, 2013 at 2:28

1 Answer 1

1

You can use the URI class to check if the third URI segment contains anything and if it does you can use show_404():

if($this->uri->segment(3) !== FALSE)
{
  show_404();
}
Sign up to request clarification or add additional context in comments.

2 Comments

absolutely simple and effective, realy loved it like a charm... but cud i use routing techniques for this??
@Saswat - I don't see anything in the URI routing section that could help you with this. It may be possible, but I don't know how.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.