Question

Basically, I have a CodeIgniter site that registers users through this url:
http://website.com/user/register/1

Unfortunately, when you pass extra arguments in the URL like this: http://website.com/user/register/1/extraargs/extraargs

Here is my code:

<?php
class User extends CI_Controller
{
    public function register($step = NULL)
    {
        if (($step!=NULL)&&($step == 1 || $step == 2 || $step == 3)) {
            if ($step == 1){
                $this->load->view('registration_step1');
            }
        } else {
            show_404();
        }
    }
}
?>

It doesn't show a 404. It simply ignores the extra arguments. I want it so that the extra arguments wouldn't affect the URL. I want to show a 404 if there are extra URL arguments. How do you do this? Also, can the extra URL segments affect security? Thanks.

Était-ce utile?

La solution

Not sure why you'd want to do that really, but you could use func_num_args() and validate from that, i.e.,

public function register($step = NULL)
{
  if ( func_num_args() > 1 ) show_404();
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top