Welcome Guest, Not a member yet? Register   Sign In
Posting forms to self or new function
#1

[eluser]Unknown[/eluser]
Hello,

I am new to MVC and frameworks so sorry if this is a dummy question.

Previously working with plain PHP I have submitted forms to the same page then in the code put:
Code:
if($_POST) {
//do form
} else {
//do something else
}

From all of the online tutorials I have noticed people post forms to a new function similar to the following:
Code:
class User extends Controller {
function login() {
// normal
}
function login_submit() {
//submit form
}
}

Is this the right way of going about things or can I post to the same function if I want?
It seems that for things like admin areas where there are lots of forms I will need double the amount of functions especially when the login() function appears to just serve a view and doesn't particularly do anything else.

Thanks

Dave.
#2

[eluser]jrtashjian[/eluser]
I like to submit forms to the same function. There is no right or wrong way to do it. Do what works for you. The first way works for me.
#3

[eluser]Drubo[/eluser]
Very good question and as well the answer.
#4

[eluser]Unknown[/eluser]
Thanks for your responses.

Think I'll stick with everything in one function.

Dave/




Theme © iAndrew 2016 - Forum software by © MyBB