我是 Laravel 的新手,无法将数据发布到控制器.我找不到相应的文档.我想在 Laravel 中做一些类似于我在 C# MVC 中做的事情.
I am new to Laravel and I'm having trouble with posting data to a controller. I couldn't find the corresponding documentation. I want to something similar in Laravel that I do in C# MVC.
<form action="/someurl" method="post">
<input type="text" name="someName" />
<input type="submit">
</form>
控制器
[HttpPost]
public ActionResult SomeUrl(string someName)
{
...
}
你应该使用路由.
你的.html
<form action="{{url('someurl')}}" method="post">
<input type="text" name="someName" />
<input type="submit">
</form>
在routes.php
Route::post('someurl', 'YourController@someMethod');
最后在 YourController.php
public function someMethod(Request $request)
{
dd($request->all()); //to check all the datas dumped from the form
//if your want to get single element,someName in this case
$someName = $request->someName;
}
这篇关于Laravel 表单发布到控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!