当我尝试在 Laravel 中使用表单登录并保存会话以在主页中重定向时,我总是收到消息说所需的电子邮件不正确,即使它是正确的
这是控制器:
public function welcome (Request $request) {
{
$this->validate($request, [
'mail' => 'required|email',
'mdp'=> 'required'
]);
$patt= patient::orderBy('created_at','desc')->get() ;
foreach ($patt as $log )
{
if (( $log->Login== $request->input('mail') ) && ( $log->Password== $request->input('mdp') ))
{
$request->session()->put('log_in', true);
return redirect('index' , ['helloo'=>$log]);
}
return back()->withErrors([
'message'=> 'Emails or password not correct!'
]) ; }
}
网站.php:
Route::Post('/index' , 'patientcontroller@welcome')->name('rahmaa');
形式:
<form class="form-signin" method="post" action="{{route('rahmaa')}}">
@csrf
<input type="text" class="form-control" name="email" placeholder="Adresse mail" data-rule="email" autofocus="" /> </br>
<input type="password" class="form-control" name="mdp" placeholder="Mot de passe" data-rule="required"/>
<button class="btn btn-primary btn-block" type="submit"> Se connecter </button> <br>
<center> <a href="inscription"> Inscrivez-vous </a> </center>
</form>
慕标5832272
三国纷争