为了账号安全,请及时绑定邮箱和手机立即绑定

对于表单,此路由不支持 GET 方法

对于表单,此路由不支持 GET 方法

PHP
慕斯709654 2024-01-19 16:46:12
我已经设置了在表单中插入数据的 POST 方法。我也在 web.php 中设置了 POST 方法。但每当我想通过表单插入数据时,它都会显示不支持 Get 方法。但我在表单和路由中都写了POST方法。这是我的代码:形式:<form action="{{url('/admin/prescription/store')}}" method="POST"> @csrfRoute::post('/admin/prescription/store','prescriptionController@store')->name('prescription.store');控制器:public function store(Request $request){    $prescription = new Prescription();    $prescription->full_name = $request->full_name;    $prescription->nid = $request->nid;    $prescription->address = $request->address;    $prescription->contactNum = $request->contactNum;    $prescription->health_cond = $request->health_cond;    $prescription->desc = $request->desc;    $prescription->save();         return redirect()        ->route('prescription.store')        ->with('success','Prescription added Successfully.'); }
查看完整描述

3 回答

?
炎炎设计

TA贡献1808条经验 获得超4个赞

这是因为您重定向到了帖子路线。重定向就像 get 请求一样。



查看完整回答
反对 回复 2024-01-19
?
阿波罗的战车

TA贡献1862条经验 获得超6个赞

这是因为你在 store() 中重定向,你应该重定向到 get 路由



查看完整回答
反对 回复 2024-01-19
?
慕容3067478

TA贡献1773条经验 获得超3个赞

要对两种类型的请求使用同一条路由,您可以执行以下操作:

Route::match(['GET', 'POST'],'/admin/prescription/store', 'ExampleController@store');



查看完整回答
反对 回复 2024-01-19
  • 3 回答
  • 0 关注
  • 29 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信