Comment puis-je fournir un retour d'erreur en ligne avec Laravel 5
Posté : 09 juil. 2019, 14:26
Je construis un formulaire en utilisant Laravel 5 et je souhaite que des messages d'erreur apparaissent en regard de la page d'authentification.
VIEW:
VIEW:
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/css/bootstrap.css" rel="stylesheet">
<link href="/css/bootstrap.min.css" rel="stylesheet">
<link href="/css/bootstrap-theme.css" rel="stylesheet">
<link href="/css/all.css" rel="stylesheet">
<link href="/css/all.min.css" rel="stylesheet">
<link href="/css/Style.css" rel="stylesheet">
<script src="/js/jquery-2.2.4.min.js"></script>
<script src="/js/bootstrap.js"></script>
<script src="/js/all.js"></script>
<script src="/js/all.min.js"></script>
<title>LOGIN</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet">
</head>
<body>
<form id="form1" action="/loginme" method="post">
<div >
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="login_form">
<div class="inputWithIcon">
<i class="fas fa-user-tie" ></i>
<input type="text" placeholder="Username" class="form-control" name="username" required />
</div>
<div class="inputWithIcon">
<i class="fas fa-unlock-alt" ></i>
<input type="password" placeholder="Password" class="form-control" name="password" required />
</div>
<br />
<input type="submit" id="submitBtn" class="btn btn-secondary btn-block login-submit-btn" value="Login"></input>
<label class="invalid-feedback" id="login_error"></label>
</div>
</div>
</form>
</body>
</html>
and this is my controller
class loginController extends Controller
{
public function login(Request $request)
{
$username = $request->input('username');
$password = $request->input('password');
$cheklogin = DB::table('users')->where(['Username'=>$username,'Password'=>$password])->get();
if(count($cheklogin) > 0)
{
echo "login successfull";
}
else
{
return view('login');
}
}
}
Pouvez vous me m'aidez s'il vous plais ?