Welcome Guest, Not a member yet? Register   Sign In
Checking if a request is POST?
#7

[eluser]hugle[/eluser]
[quote author="heavenquake" date="1266739418"]input->post is not a controller method, but a method of the input library ( http://ellislab.com/codeigniter/user-gui...input.html ).

In CodeIgniter you extend core libraries (such as input) by placing a file called MY_Input.php in your libraries folder, with the following prototype:
Code:
class MY_Input extends CI_Input {

//your extended code here

}
while still calling it with $this->input->post() as you normally would. more on that here: http://ellislab.com/codeigniter/user-gui...asses.html

in your case it would be something alá:
Code:
class MY_Input extends CI_Input {

    function post($index = '', $xss_clean = FALSE)
    {
        // this will be true if post() is called without arguments
        if($index === '')
        {
            return ($_SERVER['REQUEST_METHOD'] === 'POST');
        }
        
        // otherwise do as normally
        return parent::post($index, $xss_clean);
    }
}
[/quote]

thank you very much for this extension,it's more like CI style.Smile

I used to use this:
Code:
if($_POST)
{
   // do something
}


Messages In This Thread
Checking if a request is POST? - by El Forum - 02-20-2010, 08:43 AM
Checking if a request is POST? - by El Forum - 02-20-2010, 11:01 AM
Checking if a request is POST? - by El Forum - 02-20-2010, 01:17 PM
Checking if a request is POST? - by El Forum - 02-20-2010, 02:06 PM
Checking if a request is POST? - by El Forum - 02-20-2010, 05:32 PM
Checking if a request is POST? - by El Forum - 02-20-2010, 08:03 PM
Checking if a request is POST? - by El Forum - 02-21-2010, 06:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB