2016-04-23 94 views
-1

我建立一個網站,Laravel 5.2和我在做刀片佈局形式:Laravel5.2 NotFoundHttpException在RouteCollection.php線161:

<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', '[email protected]'); 

而且這個功能在控制器前面

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 

和URL去

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

爲什麼會出現這種情況?

回答

0

您已將表單的操作(發送數據的位置)設置爲POST(因此第二個action屬性將被忽略)。

您應該將方法設置爲POST

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

應該是:

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

謝謝它的工作原理 –

相關問題