Hello. I have made a booking form and I have a question regarding the redirection after the form is submitted. What I want : Simply redirect after submit to another route with a new view, and show a "Confirmation page with the form data". Something like this -
Thank you {$firstname, $lastname}. Your booking has been successfully submitted. We have sent you an email to {$email}, etc..
So far I've tried this
return view('client/pages/confirmation', compact('booking', $booking));
And it works and shows the data correctly. The issue is if I reload the page, the form is getting sent one more time :/
I have also tried this:
return redirect()->route('confirmation',['id'=>$booking]);
//Using this route
Route::get('/bestilling/bekreftelse/{id}', 'BookingController@confirmation')->name('confirmation');
//Using this function
public function confirmation($id) {
$booking = Booking::whereId($id)->first();
return view('client/pages/confirmation', compact('booking', $booking));
}
And now i'ts just to change the url ID and you have access to another guy's booking..
Someone knows how this can be done the safest way? With sessions?