我遇到了Laravel 5.2登录和注册的问题。我在这里使用Laravel 5.2默认login.blade.php和register.blade.php 。所有事情都顺利但当我试图注册任何用户并填写表格然后提交它不会在数据库中插入任何数据,并且在浏览器窗口中显示相同的页面。尽管我已将调试设置为true但浏览器未显示任何错误。
这是我的routes.php:
<?php use App\Member; use Illuminate\Http\Request; /* |-------------------------------------------------------------------------- | Routes File |-------------------------------------------------------------------------- | | Here is where you will register all of the routes in an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('/', function () { return view('welcome'); }); Route::get('/home', function () { return view('home'); }); Route::get('/members', 'MemberController@index'); Route::post('/member', 'MemberController@store'); Route::delete('/member/{member}', 'MemberController@destroy'); // Authentication Routes... Route::get('auth/login', 'Auth\AuthController@getLogin'); Route::post('auth/login', 'Auth\AuthController@postLogin'); Route::get('auth/logout', 'Auth\AuthController@logout'); // Registration Routes... Route::get('auth/register', 'Auth\AuthController@getRegister'); Route::post('auth/register', 'Auth\AuthController@postRegister'); /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | This route group applies the "web" middleware group to every route | it contains. The "web" middleware group is defined in your HTTP | kernel and includes session state, CSRF protection, and more. | */ Route::group(['middleware' => ['web']], function () { // }); Route::group(['middleware' => 'web'], function () { Route::auth(); Route::get('/home', 'HomeController@index'); });我在Stackoverflow中已经阅读了很多问题。但是所有这些都无法解决我的问题。这里是这些问题的一些链接:
无法在laravel 5.1中登录和注册 Laravel 5.2 /登录和/注册无效 Laravel 5.2身份验证 - 如何在每个页面中显示登录用户的名称和注销链接?如果你需要任何文件找到解决方案,请告诉我。然后我会在这里提供。
I have faced a problem with Laravel 5.2 login and register.I used here Laravel 5.2 default login.blade.php and register.blade.php.All things going well but when i trying to register any user and fill up the form and submit then it do not insert any data in database and same page show in the browser window.Browser did not showed any error though i have made debug true.
Here is my routes.php:
<?php use App\Member; use Illuminate\Http\Request; /* |-------------------------------------------------------------------------- | Routes File |-------------------------------------------------------------------------- | | Here is where you will register all of the routes in an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('/', function () { return view('welcome'); }); Route::get('/home', function () { return view('home'); }); Route::get('/members', 'MemberController@index'); Route::post('/member', 'MemberController@store'); Route::delete('/member/{member}', 'MemberController@destroy'); // Authentication Routes... Route::get('auth/login', 'Auth\AuthController@getLogin'); Route::post('auth/login', 'Auth\AuthController@postLogin'); Route::get('auth/logout', 'Auth\AuthController@logout'); // Registration Routes... Route::get('auth/register', 'Auth\AuthController@getRegister'); Route::post('auth/register', 'Auth\AuthController@postRegister'); /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | This route group applies the "web" middleware group to every route | it contains. The "web" middleware group is defined in your HTTP | kernel and includes session state, CSRF protection, and more. | */ Route::group(['middleware' => ['web']], function () { // }); Route::group(['middleware' => 'web'], function () { Route::auth(); Route::get('/home', 'HomeController@index'); });I have read many question in Stackoverflow.But all are failed to solve my problem.Here is some link of those questions:
Can not login and register in laravel 5.1 Laravel 5.2 /login & /register not working Laravel 5.2 Authentication - How can I show logged in user's name and the logout link in every page?For find solution if you need any files then please let me know.Then i will provide here.
最满意答案
你已经阅读了答案,你只是没有正确应用它。 Auth需要会话。 任何需要会话信息的路由都应该在web中间件组中。
现在,您的member , members , auth/login , auth/logout , auth/register ,“主页”和/路由都在web中间件组之外,因此它们都不会提供会话信息(这意味着它们都不可用)将显示用户登录)。
You've read the answer, you're just not applying it correctly. Auth requires sessions. Any route that needs session information should be inside the web middleware group.
Right now, your member, members, auth/login, auth/logout, auth/register, 'home', and / routes are all outside of the web middleware group, so none of them will have session information available (meaning none of them will show users as logged in).
更多推荐
发布评论