我试图在Laravel 5.3中构建身份验证。由于某些原因,我的表单数据未经RegisterUsers.php文件中的寄存器功能验证。当我填写表格并发送它时,我得到3个错误,告诉我需要3个字段;就像数据甚至没有被传递一样。我没有使用php artisan make:auth或laravel collectives,我也许应该。有什么显而易见的我在这里做错了吗?提前谢谢。
@extends('main')
@section('title','Register')
@section('content')
<form action='{{Auth::routes('auth.register')}}' method='POST'>
{{ csrf_field() }}
<div class='row well'>
<div class='col-md-6 col-md-offset-3'>
<div class='form-group'>
<label for='name'>Name</label>
<input type='text' id='name' class='form-control'>
</div>
<div class='form-group'>
<label for='email'>Email</label>
<input type='text' id='email' class='form-control'>
</div>
<div class='form-group'>
<label for='password'>Password</label>
<input type='password' id='password' class='form-control'>
</div>
<div class='form-group'>
<label for='password'>Confirm Password</label>
<input type='password' id='password' class='form-control'>
</div>
<div class='form-group'>
<label for='pw-remember'>Remember Me</label>
<input type='checkbox' id='pw-remember' class='form-control'>
</div>
<input type='submit' value='Login' class='btn btn-success btn-block'>
</div>
</div>
</form>
@endsection
// auth routes
Route::get('auth/login', 'Auth\LoginController@showLoginForm');
Route::post('auth/login', 'Auth\LoginController@login');
Route::post('auth/logout', 'Auth\LoginController@logout');
// Registration routes
Route::get('auth/register', 'Auth\RegisterController@showRegistrationForm');
Route::post('auth/register', 'Auth\RegisterController@register');
Route::get('blog/{slug}', ['as' => 'blog.single', 'uses' => 'BlogController@getSingle'])->where('slug', '[\w\d\-\_]+');
Route::get('blogs', 'BlogController@getIndex');
Route::get('/', 'PageController@getIndex');
Route::get('about', 'PageController@getAbout');
Route::get('contact', 'PageController@getContact');
Route::resource('posts', 'PostController');
答案 0 :(得分:1)
请为name
代码添加<input/>
属性
@extends('main')
@section('title','Register')
@section('content')
<form action='{{Auth::routes('auth.register')}}' method='POST'>
{{ csrf_field() }}
<div class='row well'>
<div class='col-md-6 col-md-offset-3'>
<div class='form-group'>
<label for='name'>Name</label>
<input type='text' id='name' name='name' class='form-control'>
</div>
<div class='form-group'>
<label for='email'>Email</label>
<input type='text' name='email' id='email' class='form-control'>
</div>
<div class='form-group'>
<label for='password'>Password</label>
<input type='password' id='password' name='password' class='form-control'>
</div>
<div class='form-group'>
<label for='password'>Confirm Password</label>
<input type='password' id='password' name='confirm_password' class='form-control'>
</div>
<div class='form-group'>
<label for='pw-remember'>Remember Me</label>
<input type='checkbox' id='pw-remember' class='form-control' name='pw-remember'>
</div>
<input type='submit' value='Login' class='btn btn-success btn-block'>
</div>
</div>
</form>
@endsection