Php 登录失败,即使在laravel登录中凭据完全正确
我制作了一个登录表单,虽然我过去常常输入凭据,但我的电子邮件和密码绝对正确,但这段代码向我显示了一个错误,这是我在else条件中定义的。请帮我找出我的错误 loginstudent.blade.php(登录表单) web.php(路由)Php 登录失败,即使在laravel登录中凭据完全正确,php,mysql,laravel,eloquent,Php,Mysql,Laravel,Eloquent,我制作了一个登录表单,虽然我过去常常输入凭据,但我的电子邮件和密码绝对正确,但这段代码向我显示了一个错误,这是我在else条件中定义的。请帮我找出我的错误 loginstudent.blade.php(登录表单) web.php(路由) 你是如何保存密码的?它是散列然后保存的吗?因为Auth::trunt与哈希模式匹配。如果您的密码以简单文本或其他加密形式保存,它将不起作用,并将导致不匹配 谢谢请提及您在问题中遇到的错误。这是一个简单的文本,但我的问题已解决。默认情况下,Auth::trunt签
你是如何保存密码的?它是散列然后保存的吗?因为
Auth::trunt
与哈希模式匹配。如果您的密码以简单文本或其他加密形式保存,它将不起作用,并将导致不匹配
谢谢请提及您在问题中遇到的错误。这是一个简单的文本,但我的问题已解决。默认情况下,Auth::trunt签入用户表,我的表不同。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<title>Login</title>
</head>
<body>
<div class="container">
<table class="table table-striped">
<form action="{{route('matchlogin')}}" method="post">
@csrf
<div class="container">
<label for="uname"><b>Email</b></label>
<input type="text" placeholder="Enter Email" name="email" required/> <br/>
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="pwd" required/> <br/>
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
<input type="submit" name="submit" value="Login"/>
</form>
</table>
</div>
@if(\Session::has('notmatch'))
<div class="container">
<h2> {{\Session::get('notmatch')}} </h2>
</div>
@endif
</body>
</html>
public function matchlogin(Request $request)
{
$email = $request->email;
$password = $request->pwd;
if (Auth::attempt(array('email' => $email, 'password' => $password))) {
return "success";
} else {
$request->session()->flash('notmatch', 'Email & password not match');
return redirect(route('loginstudent'));
}
}
Route::get('/loginstudent','studentcontroller@login')->name('loginstudent');
Route::post('/checklogin','studentcontroller@matchlogin')->name('matchlogin');