当用户尝试登录时我的身份验证问题很小但是用户名和密码在表中不匹配怎么回到登录页面时出错按摩
login.blade.php
<form class="login-box animated fadeInUp" action="valdateData" method="POST" >
{{csrf_field()}}
<div class="box-header">
<h2>Log In</h2>
</div>
<label for="username">Username</label>
<br/>
<input type="text" id="username" name="username">
<br/>
<label for="password">Password</label>
<br/>
<input type="password" id="password" name="password">
<br/>
<button type="submit">Sign In</button>
<br/>
<a href="#"><p class="small">Forgot your password?</p></a>
</form>
web.php
Route::post('/testgetvalue','OrdersController@GetValues');
Route::get('/ES','OrdersController@PrepareIndex');
Route::get('/loginForm','LoginController@ShowLoginPage');
Route::post('/valdateData','LoginController@checkValidate');
Route::post('login/{id}','LoginController@ShowErrorMassege');
LoginController.php
public function ShowLoginPage()
{
return view('/loginForm');
}
public function checkValidate(Request $request)
{
$username=$request->input('username');
$password=$request->input('password');
$isVald=true;
$checkValdate = \DB::table('authentications')
->where(['username'=>$username,'password'=>$password])
->get();
if(count($checkValdate) > 0)
{
$isVald=true;
session()->set('UserValidate','true');
session()->set('username',$username);
//$value=session()->get('test');
// echo "session "+$value;
return redirect('/es');
} else {
return redirect('/login/'.$isVald);
}
}
在这部分
return redirect('/login/'.$isVald);
如何返回登录页面并显示错误消息
感谢
答案 0 :(得分:0)
Foo
以下是如何执行此操作的示例,具体取决于您的validatin规则。您还可以使用costum消息foreach错误定义部分,您还应该使用&#34;使用Illuminate \ Support \ Facades \ Validator;&#34;在你的控制器