Php reload page after updating record

Posted by / 08-Feb-2020 13:35

Php reload page after updating record

But when the user clicks the "reload" or "refresh" button, the browser submits the same form fields again, sometimes with unpleasant results.

The consequences can be as minor as an extra email to support staff, or as serious as a double charge on a credit card, also known as a "duplicate transaction." How can we prevent duplicate transactions?

And once they're there, they might hit the "submit" button again.

If the form's only purpose is to do something relatively harmless like submitting email, it's not a big problem. All we have to do is generate a unique "transaction ID" when we output the form, and make sure it is passed as a hidden field when the user submits their input.

This prevents all of the major browsers from attempting to load the page from the cache.

The code below is a simple PHP/My SQL application that invites the customer to enter a credit card number and expiration date, and then sells them a widget...

When the user's form data is present, it emails that data to field is present, it thanks the user and stops.

The user can't hit "Refresh" on a URL they never actually see.

Of course, this short program does not really charge a credit card.

The browser might warn the user that clicking "reload" or "refresh" will re-submit form data, but users often fail to understand the consequences. Well, let's think about what that "reload" button actually does!

Clicking reload causes the browser to fetch the URL that is in the location bar again, and to submit whatever form data was passed along with it.

The user fills out the form and clicks "submit." Your PHP, CGI, ASP or other server-side code acts on that information and adds records to a database, or generates an email message, or what have you.

And then the user clicks "refresh," causing it all to happen again.

php reload page after updating record-70php reload page after updating record-24php reload page after updating record-39

The above is a great solution for preventing annoying double submissions of contact forms and the like.

One thought on “php reload page after updating record”

  1. (For use by customers with hearing impairments only) We may record your call so we can check we've carried out your instructions correctly and to help us improve our service.