Support the ongoing development of Laravel.io →
Authentication Validation Installation

I'm trying to get the error message to show when I attempt to login with the wrong username and password combination, so when I do that I don't get an error message showing. I'm not sure where I'm going wrong.

My controler

    namespace App\Http\Controllers;
    use Illuminate\Http\Request;
    use App\Http\Requests;
    use App\User;
    use Illuminate\Support\Facades\Auth;
    use Illuminate\Support\Facades\Input;

    class HomeController extends Controller
    {
        public function login(Request $request)
        {
            if(Auth::attempt(array('name' => Input::get('name'), 'password' => Input::get('password'))))
            {
                return redirect()->route('dashboard');
            }else{
                return redirect()->route('home')
                    ->with('message', 'Your username and password combination is wrong')
                    ->withInput();
            }
        }
    }

my index.blade.php

    @if ($errors->any())
        {{ implode('', $errors->all('<div>:message</div>')) }}
    @endif

    <div class="form-wrapper">
	    <div class="login-header">
		    <h1>Login</h1>
	    </div>

	    <div class="form_input">
		    {{ Form::open(array('url' => 'admin/')) }}
			    <div class="form_group">
				    {{ Form::label('name', 'Name') }}
				    {{ Form::text('name', '' , array("class" => "form-control")) }}
			    </div>

			    <div class="form_group password-section">
				    {{ Form::label('password', 'Password') }}
				    {{ Form::password('password', array("class" => "form-control")) }}
			    </div>

			    <div class="form_group submit_button">
				    {{ Form::submit('Submit', array("class" =>"btn btn-info submit", "role" => "button")) }}
			    </div>
		    {{ Form::close() }}
	    </div>
    </div>

My routes.php

    Route::group(['middleware' => 'web'], function()
    {
        Route::get('admin/', [
            'uses' => 'HomeController@index',
            'as' => 'home'
        ]);

        Route::post('/signin', [
            'uses' => 'HomeController@login',
            'as' => 'Login'
        ]);
    });
Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

shiva shiva Joined 24 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.