-1

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

common sense
  • 3,775
  • 6
  • 22
  • 31
  • Can you share what you have tried and what your exact problem is? See: https://stackoverflow.com/help/on-topic – Viktor Seifert Dec 05 '17 at 09:56
  • any reason you are not using the auth system and out of the box login? – lagbox Dec 05 '17 at 09:58
  • 1
    Possible duplicate of [Laravel 5.4 redirection to custom url after login](https://stackoverflow.com/questions/42177044/laravel-5-4-redirection-to-custom-url-after-login) – Masivuye Cokile Dec 05 '17 at 09:59
  • 1
    Word of advice, head over to laracasts.com, find tutorial about authentication in laravel. It will save you a lot of headache :) – jacobdo Dec 05 '17 at 10:00
  • In the error above, the problem is not redirect after successful, the problem is that whatever route you are calling does not accept a get request, my guess you have to change that route to post. – jacobdo Dec 05 '17 at 10:01
  • can you please share your route?? – Ritesh Khatri Dec 05 '17 at 10:45
  • and be sure your home.blade.php is upnder the frontEnd directory? check for typo. – Ritesh Khatri Dec 05 '17 at 10:46
  • @MasivuyeCokile the OP is not using the default Auth system in Laravel ... not a duplicate – lagbox Dec 05 '17 at 10:54

2 Answers2

-1

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.

jacobdo
  • 1,605
  • 3
  • 15
  • 34
-2

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