• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to force POST verb only for action method

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?


How about checking to see if the _POST array is greater than 1 otherwise show_404().

[eluser]Sagar Ratnaparkhi[/eluser]
Yes, you can do it like

if(!empty($this->input->get()) && count($this->input->get()) > 0 )

I did
//my code
thanks all!

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.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.