Skip to content
Advertisement

Laravel 5 input old is empty

My routes is here

Route::get('sign-up', ['as' => 'signUp', 'uses' => 'UserController@signUpGet']);
Route::post('sign-up', ['as' => 'signUpPost', 'uses' => 'UserController@signUpPost']);

Controller

return redirect('signUp')->withInput();

And View

    <form role="form" method="POST" action="{{route('signUpPost')}}"> 
        <input type="text" class="form-control" name="username" value="{{ old('username') }}">
</form>

The {{old()}} function return empty value.
EDIT
I took

NotFoundHttpException in RouteCollection.php line 145:

Advertisement

Answer

Your problem looks like you are not actually submitting the username in the first place:

<form role="form" method="POST" action="{{route('signUpPost')}}"> 
        <input type="text" class="form-control" name="username" value="{{ old('username') }}">
</form>

There is no ‘submit’ button inside the form. If you submit outside the form – then the username will not be included.

Add the submit button inside your form – then try again

<form role="form" method="POST" action="{{route('signUpPost')}}"> 
        <input type="text" class="form-control" name="username" value="{{ old('username') }}">
        <input type="submit" value="Submit">
</form>

Edit – also your controller is wrong. It should be this:

 return redirect()->route('signUp')->withInput();
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement