简体   繁体   English

如何在 Laravel 中将用户定义的数据从一个页面发送到另一个页面

[英]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.

相关问题 如何使用Laravel将数据从一页发送到另一页? - How can I send data from one page to another using Laravel? 如何将用户输入数据发送到PHP以及如何将数据从一个PHP页面发送到另一个PHP页面 - How would I send user input data to PHP & send data from one PHP page to another PHP page 如何将用户会话从一个页面发送到另一个页面直到在 php 和 mysql 中销毁 - How can I send user session from one page to another till destroyed in php and mysql 如何使用在另一个php页面的一个html页面中定义的用户输入从Oracle数据库中获取数据 - how to use a user input defined in one html page in another php page to fetch data from oracle database Laravel:如何在刀片中将变量从一页发送到另一页 - Laravel : How to send variable from one page to another in blade 如何将数据从一页传递到另一页? - How can I pass data from one page to another? Html 如何将数据从一页发送到另一页 - Html how send data from one page to another page 如何在不加载页面的情况下将数据从一页发送到另一页? - How to send data from one page to another without page load? 如何将表的数据从一个视图发送到 laravel 中的另一个视图 - how to send data of table from one view to another view in laravel 如何在Laravel中将数据从一个表发送到另一个表? - How to send data from one table to another in Laravel?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM