How to force POST verb only for action method - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How to force POST verb only for action method (/showthread.php?tid=54599) |
How to force POST verb only for action method - El Forum - 09-16-2012 [eluser]deepakaggarwal[/eluser] I've a method in controller which I want to respect only POST requests. If its a GET request it should actually be 404 Not found. How can I accomplish this? thanks How to force POST verb only for action method - El Forum - 09-16-2012 [eluser]pickupman[/eluser] How about checking to see if the _POST array is greater than 1 otherwise show_404(). How to force POST verb only for action method - El Forum - 09-16-2012 [eluser]Sagar Ratnaparkhi[/eluser] Yes, you can do it like Code: if(!empty($this->input->get()) && count($this->input->get()) > 0 ) How to force POST verb only for action method - El Forum - 11-01-2012 [eluser]deepakaggarwal[/eluser] I did Code: if ($_SERVER['REQUEST_METHOD'] === 'GET') { Reason I was looking for this: I want to have a controller which displays form when GET otherwise performs operation. For example, GET:// AddUser() will display new user form while POST:// AddUser() will perform operation and display thank you. This will help me in having one action method and play with verbs. |