我的路线在这里
Route::get('sign-up',['as' => 'signUp','uses' => 'UserController@signUpGet']); Route::post('sign-up',['as' => 'signUpPost','uses' => 'UserController@signUpPost']);
调节器
return redirect('signUp')->withInput();
和观点
<form role="form" method="POST" action="{{route('signUpPost')}}"> <input type="text" class="form-control" name="username" value="{{ old('username') }}"> </form>
{{old()}}函数返回空值.
编辑
我拿了
NotFoundHttpException in RouteCollection.PHP line 145:
您的问题看起来好像您实际上并未首先提交用户名:
原文链接:https://www.f2er.com/laravel/136026.html<form role="form" method="POST" action="{{route('signUpPost')}}"> <input type="text" class="form-control" name="username" value="{{ old('username') }}"> </form>
表单中没有“提交”按钮.如果您在表单外提交 – 则不会包含用户名.
在表单中添加提交按钮 – 然后重试
<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>
编辑 – 您的控制器也是错误的.它应该是这样的:
return redirect()->route('signUp')->withInput();