php 一个表单两个提交按钮,php – Laravel 4 – 一个表单中的两个提交按钮,并且两个提交都由不同的操作处理...

我会这样做的

如果您的表格是(2个按钮):

{{ Form::open(array('url' => 'test/auth')) }}

{{ Form::email('email') }}

{{ Form::password('password') }}

{{ Form::password('confirm_password') }}

{{ Form::close() }}

创建一个控制器’TestController’

添加路线

Route::post('test/auth', array('uses' => 'TestController@postAuth'));

在TestController中,您有一个方法可以检查单击了哪个提交以及另外两个登录和注册方法

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.

}

}

?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值