はログイン時に、laravelではなく、ホーム・ページのログインページにリダイレクトするたびにログインすることができない、ここでは、これは私はDを書かれたHAV私のコントローラのコードである私のコードLaravelにログインすることができない
ですそれはここでログイン
Route::group(['middleware' => 'checkuser'],function(){
Route::get('/home','[email protected]');
});
後に行く必要がありますログインコード
public function loginprocess(Request $request){
$username = $request->get('username');
$password = $request->get('password');
$checkuser = Users::selectRaw("Count(*) as Total")->where('email','=',$email)->first();
if(intval($checkuser->Total) > 0){
$getpassword = Users::select("password")->where('email','=',$email)->first();
if(password_verify($password,$getpassword->password)){
//if($username == $checkuser && $password == $getpassword){
$request->session()->set('email',$email);
return redirect('/home');
}else{
return redirect('/login');
}
}else{
return redirect('/login');
}
}
ルートコードは、フォーム
の私のHTMLコードです<form class="form-horizontal" role="form" method="post" action="loginprocess">
{{ csrf_field() }}
<div class="form-group fg-float">
<div class="fg-line">
<label class="fg-label">Email Address</label>
<input type="email" id="email" name="email" value="{{ old('email') }}" class="input-sm form-control fg-input">
</div>
</div>
<div class="form-group fg-float">
<div class="fg-line">
<label class="fg-label">Password</label>
<input type="password" id="password" name="password" class="input-sm form-control fg-input">
</div>
</div>
<button class="btn palette-Teal bg" name="Login">Sign in</button>
<div class="m-t-20">
<a data-bg="blue" class="palette-Teal text d-block m-b-5" href="register">Create an Account</a>
<a data-bg="purple" class="palette-Teal text" href="forget">Forgot Password?</a>
</div>
</form>
あなたがここに$request->session()->set('email',$email);
を呼び出す$email
変数は、その行の前にどこにも存在しないため
あなたは自分のログインコードを書いていますか? そして、checkuserミドルウェアのコードを表示できますか? – Bostjan
@Bostjan <?php 名前空間App \ Http \ Middleware; クローズを使用します。 クラスチェックユーザー { パブリック関数ハンドル(次の$要求、閉鎖$) { 場合($要求 - >セッション() - >)[メール](取得=== NULL){ リターンリダイレクト( '/ログイン'); } elseif($ request-> session() - > get( 'email')!== null){ returnリダイレクト( '/ home'); } return $ next($ request); } } – Aavin
@Aavin私の答えがあなたを助けた場合は、回答としてマークしてください。お願いします。ありがとうございました。 – EddyTheDove