Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 如何在验证后检索POST数据?_Laravel_Laravel 5.4 - Fatal编程技术网

Laravel 如何在验证后检索POST数据?

Laravel 如何在验证后检索POST数据?,laravel,laravel-5.4,Laravel,Laravel 5.4,无论我提交登录、注册或忘记密码表单,我都无法检索POST数据。这是我的表单标签: <form class="form-horizontal" role="form" method="POST" action="{{ url('/login') }}"> 登入表格: <form class="form-horizontal" role="form" method="POST" action="{{ url('/login') }}">

无论我提交登录、注册或忘记密码表单,我都无法检索POST数据。这是我的表单标签:

<form class="form-horizontal" role="form" method="POST" action="{{ url('/login') }}">
登入表格:

                <form class="form-horizontal" role="form" method="POST" action="{{ url('/login') }}">
                    {{ csrf_field() }}

                    <div class="form-group{{ $errors->has('username') ? ' has-error' : '' }}">
                        <label for="username" class="col-md-4 control-label">Username</label>

                        <div class="col-md-6">
                            <input id="username" type="text" class="form-control" name="username" value="{{ old('username') }}" required autofocus>

                            @if ($errors->has('username'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('username') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>

                    <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
                        <label for="password" class="col-md-4 control-label">Password</label>

                        <div class="col-md-6">
                            <input id="password" type="password" class="form-control" name="password" required>

                            @if ($errors->has('password'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('password') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-md-6 col-md-offset-4">
                            <div class="checkbox">
                                <label>
                                    <input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}> Remember Me
                                </label>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-md-8 col-md-offset-4">
                            <button type="submit" class="btn btn-primary">
                                Login
                            </button>

                            <a class="btn btn-link" href="{{ url('/password/reset') }}">
                                Forgot Your Password?
                            </a>
                        </div>
                    </div>
                </form>

{{csrf_field()}}
用户名
@如果($errors->has('username'))
{{$errors->first('username')}
@恩迪夫
密码
@如果($errors->has('password'))
{{$errors->first('password')}
@恩迪夫
记得我吗
登录
我的路线:

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//Auth
Auth::routes();

//Homepage
Route::get('/', 'HomeController@index');
Route::get('/home', 'HomeController@index');
Route::get('/logout', '\App\Http\Controllers\Auth\LoginController@logout');

你当然可以。您可以通过以下命令检索登录数据:

string username = Request["username"];
string password = Request["password"];
如果您的html是:

<input type="text" name="username"/><br/>
<input type="password" name="password"/><br/>

您的路由文件中的
/login
路由是什么?我有
Auth::routes()在我的控制器中,它必须在那里定义。我想我们需要看到更多的代码来了解您的问题所在。我已经用我的代码编辑了我的问题,但代码不起作用。它说常数不存在。当我使用
$request
时,该值为空。请求(“用户名”)也是如此
<input type="text" name="username"/><br/>
<input type="password" name="password"/><br/>
string username = Request["username"];
string password = Request["password"];