0

i saw this function 'is_post' at this website:

http://www.kylenoland.com/a-comprehensive-guide-to-securing-codeigniter-2-x-with-ben-edmunds-ion-auth/

class MY_Controller extends CI_Controller
{
    public function is_post()
    {
        return $_SERVER['REQUEST_METHOD'] == 'POST' ? TRUE : FALSE;
    }
}

May i know the correct way to use this function and how? thanks. regards, zs

user1884324
  • 693
  • 5
  • 14
  • 21

1 Answers1

2

One of the advantages of using your own parent controller is that the common checks can be checked at central position. so when you are creating/defining a controller, you can inherit from your own controller, like below to use parent class methods:

class User_Controller extends MY_Controller
{
    public function login()
    {
        if($this->is_post()){
            //login check and redirect if successfull.
        }
        $this->load->view("login");
    }
}
Adeel
  • 19,075
  • 4
  • 46
  • 60