RouteCollection.php第161行中的Laravel5.2 NotFoundHttpException:

时间:2016-04-23 05:34:35

标签: laravel xampp laravel-5.2

我正在使用Laravel 5.2建立一个网站,我在布局刀片中做了一个表单:

<form action="POST"  action="{{url('subscribe')}}" class="searchform">
       {!! csrf_field() !!}
   <input type="email" placeholder="Your email address" name="email" />
  <button type="submit" class="btn btn-default" ><i class="fa fa-arrow-circle-o-right"></i></button>
<p>Get the most recent updates from <br />our site and be updated your self...</p>
    </form>

这是我的路线

Route::post('/subscribe', 'Front@subscrib');

此功能在控制器Front

public function subscrib()
    {
        echo"we in subsc function";
       if (Request::isMethod('post')) {
            Subscribe::create([
                'email' => Request::get('email')

            ]);
       }

    }

但是当我在表单中写电子邮件时,我收到了这个错误:

NotFoundHttpException in RouteCollection.php line 161:
in RouteCollection.php line 161
at RouteCollection->match(object(Request)) in Router.php line 823
at Router->findRoute(object(Request)) in Router.php line 691

网址转到

http://localhost/larashop/public/POST?_token=ALqduK9gW6Xdnq9iOJzyu7kMji1z3LCXDgeQehoO&email=azharnabil%40yahoo.com

为什么会这样?

1 个答案:

答案 0 :(得分:0)

您已将表单的操作(发送数据的位置)设置为POST(结果会忽略第二个action属性。)

您应该将方法设置为POST

<form action="POST"  action="{{url('subscribe')}}" class="searchform">

应该是:

<form method="POST"  action="{{url('subscribe')}}" class="searchform">