【问题标题】:how to update a table in laravel 5.2如何在 laravel 5.2 中更新表格
【发布时间】:2016-10-20 02:37:04
【问题描述】:

当我单击提交按钮时,它会显示 MethodNotAllowedHttpException 第 218 行,我的路线似乎没问题。

我的刀片是`id")}} " method = "post">

{{csrf_field()}} {{ method_field('PUT') }}

<table>
    <tr>
        <td>Name</td>
        <td>
            <input type = 'text' name = 'name' value = '{{ $users->name}}'/>
        </td>
    </tr>
    <tr>
        <td colspan = '2'>
            <input type = 'submit' value = "Update student" />
        </td>
    </tr>
</table>

`

我的路线是Route::post('edit/{id}','StudUpdateController@edit');

控制器

public function show($id){ $users =User::findOrFail($id); return view('stud_update',['users'=>$users]); } public function edit(Request $request,$id) { dd("welcome"); $name = $request->input('name'); DB::update('update users set name = ? where id = ?',[$name,$id]); echo "Record updated successfully.<br/>"; echo '<a href = "/edit-records">Click Here</a> to go back.'; }

it doesn't diplay the welcome message

【问题讨论】:

    标签: php


    【解决方案1】:

    我是使用 Route::put() 而不是 route::post()。它现在就像一个魅力

    【讨论】:

      猜你喜欢
      • 2017-02-25
      • 2016-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-10
      • 2023-03-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多