Welcome Guest, Not a member yet? Register   Sign In
Can you run different controller methods for POST and GET?
#1

[eluser]Unknown[/eluser]
Having previously used the DooPHP framework, I am making the move to CodeIgniter, as it has been recommended to me by my colleagues.

Similarly to DooPHP, CodeIgniter has a routes config file, which can take a list of URI/method pairs.

In DooPHP, you could have a basic get request to 'http://www.mysite.com/sign-up' run a method in the controller called "signUp" and a post request to the same URL run a different method. i.e. "postSignUp", as show below.

$route['get']['/sign-up'] = array('PublicController', 'signUp');
$route['post']['/sign-up'] = array('PublicController', 'postSignUp');

Is it possible to do this at routes level in CodeIgniter, without having to do some conditional logic in the controller itself? I can't see anything like this in the documentation - hopefully someone can enlighten me to what I am hoping to be true! Smile

Cheers


Messages In This Thread
Can you run different controller methods for POST and GET? - by El Forum - 08-03-2014, 11:15 AM



Theme © iAndrew 2016 - Forum software by © MyBB