Laravel表单发布到控制器

编程入门 行业动态 更新时间:2024-10-27 16:37:36
本文介绍了Laravel表单发布到控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是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) { ... }

推荐答案

您应该使用route.

You should use route.

您的.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表单发布到控制器

本文发布于:2023-10-26 10:53:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1529927.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   控制器   Laravel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!