【发布时间】:2019-12-01 10:47:59
【问题描述】:
我在 web.php 中将我的路由定义为 Post 方法。并且 csrf 令牌也添加到 form 中。 Route:list 命令运行良好并显示该发布路线。但是当我提交表单时,它显示此路由不支持 POST 方法。支持的方法:GET、HEAD。
@csrf 添加到表单标签。 php artisan route:list 工作正常,显示已定义的发布路由。
<form method="POST" method="plantouser">
@csrf
<h1>Select Plan</h1>
<div>
<select name="plans" class="form-control">
@foreach($plan as $plan)
<option value="{{$plan->planamount}}">{{$plan->planname}} of {{ $plan->planamount}}</option>
@endforeach
</select>
</div>
<div class="clearfix"></div>
<div class="separator">
<button type="submit">Submit</button>
</div>
</form>
Route::post('/plantouser','PlanController@planToUser');
public function planToUser(Request $request){
$payment=Planpaymentdetail::create([
'paymenttype'=>'online',
'pyamount'=>$price,
'pycoinamount'=>$dec['result']['amount'],
'pytxnhash'=>$dec['result']['txn_id'],
'pyinitiatetime'=>now(),
]);
return redirect()->back()->with('success','Plan selected successfully');
}
this image showing data which is post by form to server
预期结果是重定向到带有消息的 url 但是在获取 MethodNotAllowedHttpException 时,该路由不支持 POST 方法。支持的方法:GET、HEAD。
【问题讨论】:
-
用完整的表格更新问题。
标签: php laravel routes methodnotfound