Checking if a request is POST? |
[eluser]Unknown[/eluser]
How can I check if a request was submitted with the POST method (does CI offer a shorter way than "if($_SERVER['REQUEST_METHOD'] === 'POST')")?
[eluser]sqwk[/eluser]
Code: $something = $this->input->post('something'); http://ellislab.com/codeigniter/user-gui...input.html
[eluser]skunkbad[/eluser]
[quote author="squawk" date="1266706903"] Code: $something = $this->input->post('something'); http://ellislab.com/codeigniter/user-gui...input.html[/quote] That only checks for the existence of $_POST['something'], so it won't work.
[eluser]heavenquake[/eluser]
I don't believe there is, but you could write a quick helper function that did it for you. Personally I extend input->post() to, if no argument is given, return TRUE if anything has been posted at all. You might want to do something similar.
[eluser]Unknown[/eluser]
How do you override controller methods, preserving the old one? Like in Ruby I'd do Code: class Controller Sorry for the example in another lang, my PHP is rusty.
[eluser]heavenquake[/eluser]
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 { in your case it would be something alá: Code: class MY_Input extends CI_Input {
[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 { in your case it would be something alá: Code: class MY_Input extends CI_Input { thank you very much for this extension,it's more like CI style. ![]() I used to use this: Code: if($_POST) |
Welcome Guest, Not a member yet? Register Sign In |