我对laravel Framework很新。
问题是我在单击表单按钮时定义了一个简单的控制器tp函数。
我的表单是
<form url="{{ action('loginController@login') }}" method="POST">
<input type="text" name="username" />
<input type="password" name="password"/>
<label class="checkbox">
<input type="checkbox" value="remember-me" id="rememberMe" name="rememberMe"> Remember me
</label>
<button type="submit">Login</button>
</form>
我的路线是;
Route::get('/', function()
{
return View::make('login');
});
Route::post('/login, loginController@login');
loginController.php
public function login(Request $req)
{
echo 'blah';
}
问题是当我点击按钮时没有任何反应,但错误
Whoops, `looks like something went wrong.`
有人可以帮忙吗
注意:已经解决了其他类似的问题,但没有任何进展。如果有人能够提供帮助,我们非常感谢
泰
编辑:
我的堆栈跟踪有点
NotFoundHttpException in compiled.php line 8912:
in compiled.php line 8912
at RouteCollection->match(object(Request)) in compiled.php line 8264
at Router->findRoute(object(Request)) in compiled.php line 8212
at Router->dispatchToRoute(object(Request)) in compiled.php line 8207
at Router->dispatch(object(Request)) in compiled.php line 2419
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 3286
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9948
at Pipeline->then(object(Closure)) in compiled.php line 2366
at Kernel->sendRequestThroughRouter(object(Request)) in compiled.php line 2350
at Kernel->handle(object(Request)) in index.php line 54
答案 0 :(得分:1)
在您的routes.php登录路线中缺少单个qoute。它应该是这样的 -
Route::post('/login', 'loginController@login');
你可以用这个代替你的代码 -
<form action="{{ url('login')}}" method="POST">
{!! csrf_field() !!}
<input type="text" name="username" />
<input type="password" name="password"/>
<label class="checkbox">
<input type="checkbox" value="remember-me" id="rememberMe" name="rememberMe"> Remember me
</label>
<button type="submit">Login</button>
</form>
希望这会对你有所帮助。