为什么我无法在Laravel 5.2中注册和登录?(Why i can not register and login in Laravel 5.2?)

系统教程 行业动态 更新时间:2024-06-14 16:57:40
为什么我无法在Laravel 5.2中注册和登录?(Why i can not register and login in Laravel 5.2?)

我遇到了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).

更多推荐

本文发布于:2023-04-13 12:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/504e509d3619dc3ba82a06fbfa70e0c2.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Laravel   login   register

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!