更新时间:2021-09-11 22:31:53
我会怎么做
如果您的表单是(2 个按钮):
If your form is (2 buttons):
{{ Form::open(array('url' => 'test/auth')) }}
{{ Form::email('email') }}
{{ Form::password('password') }}
{{ Form::password('confirm_password') }}
<input type="submit" name="login" value="Login">
<input type="submit" name="register" value="Register">
{{ Form::close() }}
创建一个控制器'TestController'
Create a controller 'TestController'
添加路线
Route::post('test/auth', array('uses' => 'TestController@postAuth'));
在 TestController 中,您将有一种方法来检查单击了哪个提交,以及另外两种用于登录和注册的方法
In TestController you'd have one method that checks which submit was clicked on and two other methods for login and register
<?php
class TestController extends BaseController {
public function postAuth()
{
//check which submit was clicked on
if(Input::get('login')) {
$this->postLogin(); //if login then use this method
} elseif(Input::get('register')) {
$this->postRegister(); //if register then use this method
}
}
public function postLogin()
{
echo "We're logging in";
//process your input here Input:get('email') etc.
}
public function postRegister()
{
echo "We're registering";
//process your input here Input:get('email') etc.
}
}
?>