douningchang3610
2017-12-05 09:52 阅读 36

使用php framework laravel登录后重定向页面

I'm trying to show a page from myController after successful to login.

$email = $req->input('username');
$pass = $req->input('password');
$login = DB::table('for_login')->where(['E_mail'=>$email, 'Password'=>$pass])->get();
if(count($login)>0) {              
    return view('frontEnd.Home');
} else {
    echo "Invalid username/password";
}

How can I redirect a page after a successful login?

delAction

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • dongyuan8024 dongyuan8024 2017-12-05 09:58

    Go to AuthController.php and add authenticated method'

    protected function authenticated($request){
        return view('frontEnd.home');
    }
    

    The built-in authentication functionality of laravel looks for authenticated method upon successful login and performs it, if it is declared. Hope this helps.

    点赞 评论 复制链接分享
  • douqian5920 douqian5920 2017-12-05 10:31

    try this:

    $email = $req->input('username');
    $pass = $req->input('password');
    $user = DB::table('for_login')->where('E_mail', $email)->fisrt();
    if( count($user) > 0){
        if($user->pass == $pass)
           return view('frontEnd.Home');
        else
           return "Invalid password";
    else
        return "Invalid username";
    
    点赞 评论 复制链接分享
  • duanping3587 duanping3587 2017-12-05 10:45

    use header("location:page.php");

    点赞 评论 复制链接分享

相关推荐