When I submit my user form, nothing happens:
I don't understand why nothing is happening. If I change the "POST" method to "PUT", it only redirects me to the index page. Please help. Thank you.
CRUD Route:
use IlluminateSupportFacadesRoute;
use AppHttpControllersPostsController;
Route::resource('posts', PostsController::class);
Store function within PostsController:
public function store(Request $request)
{
$request->validate([
'Product1' => 'required',
]);
$post = new Posts();
$post->Product1= $request->Product1;
$post->save();
return redirect()->route('posts.index')->with('success', 'Post created successfully');
}
HTML form:
<form method="POST" action="{{ route('posts.store') }}" enctype="multipart/form-data">
@csrf
<table class="table" style="border-style: none;">
<tr>
<th>{{ __('Product1:') }}</th>
<td><input type="text" name="Product1" class="form-control"></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" class="btn btn-primary">
</td>
</tr>
</table>
</form>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…