【问题标题】:How to pass data when redirecting to another page?重定向到另一个页面时如何传递数据?
【发布时间】:2020-08-20 02:31:02
【问题描述】:

我想在使用该数据重定向到另一个页面时传递用户数据并在该页面中使用它。

$mobile = (int) $request->mobile;

        $user = User::where('mobile',$mobile)->first();
        if ($user->count() > 0 && Hash::check($request->password, $user->password))
        {
            return redirect('/user_info')->with('user',$user);
        }

我想在其中使用用户数据的视图:

  <div class="row">
        <h3>Valnteer: {{ $user->name }}</h3>
    </div>

我遇到的问题是:

未定义变量:用户

【问题讨论】:

标签: php laravel


【解决方案1】:

您需要将数据存储在session

为了只传递一次数据,有一个名为flashing 的概念供您使用。

【讨论】:

    猜你喜欢
    • 2018-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多