【问题标题】:Laravel5.2 NotFoundHttpException in RouteCollection.php line 161:RouteCollection.php 第 161 行中的 Laravel5.2 NotFoundHttpException:
【发布时间】:2016-08-16 20:47:40
【问题描述】:

我正在使用 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');

而且这个函数在控制器前面

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

为什么会这样?

【问题讨论】:

    标签: laravel xampp laravel-5.2


    【解决方案1】:

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

    您应该将 方法 设置为 POST

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

    应该是:

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

    【讨论】:

      猜你喜欢
      • 2018-07-29
      • 2016-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-01
      • 2016-07-03
      • 2016-10-13
      相关资源
      最近更新 更多