0

I have a website, got it developed from someone, Need help in redirecting back after login in php.

After Login it redirects to Home Page. But i want user to go back where he came from.

logincontroller.php

    public function checklogin(Request $request){
        $phone = DB::table('users')->where('contact','=',$request->input('code').$request->input('contact'))->get();
        if(count($phone)>0){
            $user_data = array(
                'email' => $phone[0]->email,
                'password' => $request->get('password')
            );

            if(Auth::attempt($user_data)){
                return redirect('/');
            }else{
                return back()->with('error','wrong_details');
            }
        }else{
            return back()->with('error','wrong_details');
        }
    }
Makdous
  • 1,447
  • 1
  • 12
  • 24
Sanjeev
  • 1
  • 1
  • Does this answer your question? [How to return back twice in Laravel?](https://stackoverflow.com/questions/36098589/how-to-return-back-twice-in-laravel) – Makdous May 09 '20 at 17:23
  • I tried the way you suggested earlier. But i dont know where this all i can found. "middleware inside kernel.php file inside the $middlewareGroups array in the 'web' key," i dont know how to create all this. and where to post the code in this Please Help. – Sanjeev May 09 '20 at 18:08
  • @Makdous Hello sir, Can you please look at my problem and please help me solving this. i will be in debt for eternity. as i dont know anything about php. – Sanjeev May 12 '20 at 22:16
  • What **Laravel** version are you using? – Makdous May 12 '20 at 23:38
  • @Makdous searched internet. they said i should look in composer.json. "guzzlehttp/guzzle": "~6.3.3" This is written there. and i looked in composer.lock too as internet suggested so "name": "guzzlehttp/guzzle", "version": "6.3.3", this is written there. – Sanjeev May 13 '20 at 13:03
  • Anyone here to help me? – Sanjeev May 15 '20 at 15:55

0 Answers0