[英]How can I send a user defined data from one page to another in Laravel 7
PS -I am not going to use Session Flash
as answered by someone in a similar question here . PS - 我不会使用
Session Flash
,正如有人在此处类似问题中回答的那样。
I have a page which lets a user select if s/he has selected Value 1 or Value 2. Based on that, the user will be sent to another page, which will be sent to another page.我有一个页面,如果用户选择了值 1 或值 2,则允许用户 select。基于此,用户将被发送到另一个页面,该页面将被发送到另一个页面。
Here is my blade这是我的刀片
Page 1第 1 页
<select id="type" name="type">
<option value="1">Value 1</option>
<option value="2">Value 2</option>
</select>
<a href="{{url('page2')}}">Click Here</a>
Page 2第2页
You have selected {{$type}} <-------- Value 1/Value 2
But, I am not sure how to get the data in page 2.但是,我不确定如何获取第 2 页中的数据。
Use a simple HTML form.使用简单的 HTML 表格。
<form method="POST" action="{{ url('page2') }}">
<select id="type" name="type">
<option value="1">Value 1</option>
<option value="2">Value 2</option>
</select>
</form>
So then, on page 2 you can do {{ $type }}
only if you have a controller like:那么,在第 2 页上,只有当您有 controller 时,您才能执行
{{ $type }}
,例如:
public function show(Request $request) {
return view('name_of_view_for_page_2', ['type' => $request->input('type')]);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.