亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何將值從輸入文本框傳遞到拉拉維爾中的另一個頁面

如何將值從輸入文本框傳遞到拉拉維爾中的另一個頁面

PHP
郎朗坤 2022-09-17 21:37:24
索引控制器如下所示<?phpnamespace App\Http\Controllers;use Illuminate\Http\Request;class IndexController extends Controller{    public function index()    {        return view('welcome');    }    public function about()    {        return view('about');    }  public function contact()  {    return view('contact');  }  public function thanks(Request $request)  {    $request->validate(['firstname' => ['required', 'alpha_num']]);    return view('thanks');  }}接觸刀片.php在下面@extends('welcome')@section('content')          <div>            <h2>Contact Page</h2>            <form method="post" action="{{route("thanks")}}">              @csrf<input type="text" name="firstname"/>              <input type="submit"/>            </form>            @if ($errors->any())            <div class="alert alert-danger">              <ul>                @foreach ($errors->all() as $error)                <li>{{ $error }}</li>                    @endforeach              </ul>            </div>                @endif                  </div>  @endsection謝謝刀片.php@extends('welcome')@section('content')<div>  <h2>Thanks</h2>Thank you {{ $firstname }}</div>@endsection歡迎刀片.php  <div class="flex-center position-ref full-height">            <div class="content">                <div class="title m-b-md">                    app                </div>                <div class="links">                    <a href="{{ route('about')  }}">About</a>                    <a href="{{ route('contact')  }}">contact</a>                </div>                <h1>{{$firstname}}</h1>                <div>                    @yield('content')                </div>            </div>        </div>當我在 welcome.blade 中單擊“聯系人”時.php它會將我帶到“聯系人”頁面,其中文本框是按壓的 。輸入的值應顯示在“謝謝”.php中。我需要在文本框中輸入的值顯示在感謝.blade中.php當我單擊提交時。提前致謝
查看完整描述

1 回答

?
largeQ

TA貢獻2039條經驗 獲得超8個贊

數據需要顯式傳遞到視圖。出于希望顯而易見的原因,它不能作為變量在全球范圍內訪問。

例如

return view('thanks', ['firstname' => 'Your First Name']);


查看完整回答
反對 回復 2022-09-17
  • 1 回答
  • 0 關注
  • 136 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號