提交表单时重定向到错误的路由

时间:2017-05-12 14:33:16

标签: php forms laravel routes

我正在提交我的登录表单并定义路由操作=“{{route('signin')}}”但它正在将用户重定向到登录路由。

表单代码在这里。

<c:forEach items="${ch}" var="contractHeader">
    ... Elements to show each data
    <c:forEach items="${ch.contractEntitlements}" var="contractEntitlement">
        ... Elements to show each data

路线中的代码在这里。

<form  action="{{route('signin')}}" method="post" role="form">

                   <div class="form-group {{ $errors->has('email') ? ' has-error' : '' }}">
                       <label>Enter Email : </label>

                           <input placeholder="Enter Email" name="email" type="text" class="form-control" value="{{Request::old('email')}}">
                           @if ($errors->has('email'))
                               <span class="help-block">
                                <strong>{{ $errors->first('email') }}</strong>
                            </span>
                           @endif

                    </div>


                    <div class="form-group {{ $errors->has('password') ? ' has-error' : '' }}">
                        <label>Enter  Password :</label>
                        <input placeholder="Enter Password" type="password" name="password" class="form-control" value="{{Request::old('password')}}">
                           @if ($errors->has('password'))
                               <span class="help-block">
                                <strong>{{ $errors->first('password') }}</strong>
                            </span>
                           @endif

                    </div>

                {{csrf_field()}}
                    <input class="btn btn-outline btn-danger" type="submit" value="submit" title="Login">


            </form>

2 个答案:

答案 0 :(得分:2)

将路线更改为:

Route::post('/signin',[
  'uses' => 'userController@postSignIn',
  'as' => 'signin',
]);

答案 1 :(得分:2)

Route::post('/signin',[
    'uses' => 'userController@postSignIn',
    'as' => 'signin'
]);

只需删除“auth”中间件,因为它不允许在登录前访问该方法。