phpRoute::controller('user','UserController');//UserController.php//www.test.com/user/regfunction postReg(){}//www.test.com/user/loginfunction postLogin(){ if(reg) { //判断登陆密码 } esle { $this-> postReg();//把传递过来的参数去注册 }}
When accessing the Www.test.com/user/login, if the wood has the registration, need to call the Postreg method registration, but $this->postreg () This is the Get method, and the parameters of the post can not pass the past, what should I do?
Reply content:
phpRoute::controller('user','UserController');//UserController.php//www.test.com/user/regfunction postReg(){}//www.test.com/user/loginfunction postLogin(){ if(reg) { //判断登陆密码 } esle { $this-> postReg();//把传递过来的参数去注册 }}
When accessing the Www.test.com/user/login, if the wood has the registration, need to call the Postreg method registration, but $this->postreg () This is the Get method, and the parameters of the post can not pass the past, what should I do?
Users to log in, you find that users do not have an account, automatically help to register, your product manager agree with this logic? What if the user submits the wrong information? For example, the password was mistaken. You still have to have a registration page, let the user register themselves.
It is unreasonable to request another action in one action. Of course, you can do it too:
Postreg is an HTTP request address that you can emulate in Postlogin HTTP request Postreg, such as using curl.
There is a more reasonable approach, define a method or class createUser($data) , this method can be called in Postreg, can also be called in Postlogin, where you want to tune can be. The method of verifying registration information can also be placed in that class.
What you really need is code reuse.