Php 在laravel中,此路由不支持POST方法。支持的方法:GET、HEAD Plz
当我更新值时,我在Laravel中遇到了一个新的问题。拉雷维尔的消息是 此路由不支持POST方法。支持的方法:GET,HEAD 我也使用这些方法(Php 在laravel中,此路由不支持POST方法。支持的方法:GET、HEAD Plz,php,laravel,version,Php,Laravel,Version,当我更新值时,我在Laravel中遇到了一个新的问题。拉雷维尔的消息是 此路由不支持POST方法。支持的方法:GET,HEAD 我也使用这些方法(@csrf\u field和{{method\u field('PUT')}}),但结果为零 HTML表单 <form action="{{ $value[0]->id }}" method="post"> <input type="hidden" name="_token" value="<?php echo
@csrf\u field
和{{method\u field('PUT')}}
),但结果为零
HTML表单
<form action="{{ $value[0]->id }}" method="post">
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
<h1>This Is Update Form</h1>
<table border="1" id="customers">
<tr>
<td>Name</td>
<td>
<input type="text" name='name' value="{{ $value[0]->name }}">
</td>
</tr>
<tr>
<td>Email</td>
<td>
<input type="text" name='email' value="{{ $value[0]->email }}">
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Submit">
</td>
</tr>
</table>
</form>
<form action="{{ "/post/" . $value[0]->id }}" method="post">
表单中的操作是错误的。试试这个:
<form action="{{ "/post/" . $value[0]->id }}" method="post">
您向表单操作传递了错误的路径。将您的
表单操作从更改为
:
<form action="{{ $value[0]->id }}" method="post">
使用命名路由并为路由命名,而且我已经修复了路由问题,以在url中接受param,我们必须使用
{{param_name}}
,在您的情况下是{id}
Route::post('post/{id}','StudInsertController@update')->name('update.student');
然后以你的形式
<form action="{{ route('update.student', $value[0]->id) }}" method="post">
@csrf
/**Your rest of html form*/
</form>
谢谢在您的表单中,action URL应该是这样的
<form action="{{ 'post/'.$value[0]->id }}" method="post">
这将解决您的问题您将错误的URL放入操作中,请check@kashif如果它帮助你将它标记为已接受的答案,那么其他人也将从中受益。谢谢你再次解决了我的问题
Route::post('post/{id}','StudInsertController@update')->name('update.student');
<form action="{{ route('update.student', $value[0]->id) }}" method="post">
@csrf
/**Your rest of html form*/
</form>
<form action="{{ url('post/'.$value[0]->id) }}" method="post"> @csrf
/**Your rest of html form*/
</form>
<form action="{{ 'post/'.$value[0]->id }}" method="post">
Route::post('post/{id}','StudInsertController@update');