简体   繁体   中英

how to update a table in laravel 5.2

when i click my submit button it gives MethodNotAllowedHttpException line 218 my route seems to be Ok.

my blade is`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>

`

MY ROUTE IS Route::post('edit/{id}','StudUpdateController@edit');

Controller

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM