0

I have a probleme with submit form (booking) it re-submit on page reload

this is code of conditions to post :

if ( 'POST' == $_SERVER['REQUEST_METHOD'] && ! empty( $_POST['action'] )
 && $_POST['action'] == "new_post" ){ 
       if(!empty($_POST['start']) || !empty($_POST['end'])){
        // submit and send email}  
}

after submit it show thank message and details of booking ( else it shows errors and the form) but if user reload page it re-submit a post again in database!

can someone give me an idea , i tried to unset $_POST['end'] and $_POST['end'] but nothing works

Thank you for your support

AmenzO
  • 409
  • 7
  • 19

1 Answers1

0

There is something called Post Redirect Get pattern. You can use this pattern to avoid post request resubmission on reload. After post request do a redirect rather than directly sending success message

for reference

https://stackoverflow.com/questions/6320113/how-to-prevent-form-resubmission-when-page-is-refreshed-via-php#=

Community
  • 1
  • 1
Vibhanshu
  • 522
  • 3
  • 14
  • its not a basic success message but booking confirmation and its details and offer to user to download the confirmation page in pdf. – AmenzO Nov 05 '15 at 18:30