In Laravel 10, you can use the "session" to display flash messages to users. Flash messages are temporary messages that are stored in the session and displayed to the user on the next request. They are commonly used to provide feedback or notifications after a user action.
Step 1 : Create Route
Route::post('/submit', 'FormController@submit');
Step 2 : add code in FormController
public function submit(Request $request)
{
// Process the form submission
// Add a success flash message
$request->session()->flash('success', 'Form submitted successfully!');
return redirect()->back();
}
Step 3 : add code in Blade File
@if(session('success'))
<div class="alert alert-success">
{{ session('success') }}
</div>
@endif
here, success is session variable you can use diffrent name, but make sure flash variable and session print variable are same.
Thank You