所以,我从laravel开始。尝试将表单发布到同一页面。这是我到目前为止的一切
routes.php
Route::get('/', 'HomeController@showWelcome');
Route::group(array('before' => 'csrf'), function () {
Route::post('contactus', 'HomeController@sendEmail');
});
hello.php
<?php echo Form::open(array('action' => 'HomeController@sendEmail'))?>
input fields here
<?php echo Form::close() ?>
家庭控制器
public function showWelcome()
{
return View::make('hello');
}
public function sendEmail()
{
print_r($_POST);exit;
}
问题:表单被发布到URL public / contactus
有人可以指出我在做什么真正愚蠢的事情吗?
routes.php
Route::get('/', 'HomeController@showWelcome');
Route::post('/', array(
'before' => 'csrf', // csrf filter
'uses' => 'HomeController@sendEmail' // the controller action to be used
));
hello.php
<?php echo Form::open(array('action' => 'HomeController@sendEmail')) ?>
<!-- input fields here -->
<?php echo Form::close() ?>
HomeController.php
Public function showWelcome()
{
return View::make('hello');
}
public function sendEmail()
{
$data = Input::all();
print_r($data);
// return the same view but with posted fields in the $data array
return View::make('hello', $data);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句