Search code examples
htmlposting

Posting form data


I have an HTML form which I want to post data to then display some text to the user. I've heard several people discuss this idea:

should the user go from [form page] -> [processing form post page] -> [display page] or should the user just go to a combined [form page] -> [processing form / display page]

I've heard arguments the former is more secure while the latter is less redirects.

What are some answers?


Solution

  • To avoid caching issues, resubmission on refresh issues and similar problems: Use the POST-REDIRECT-GET pattern.

    1. Browser makes HTTP POST request with form data
    2. Server processes data and responds with a redirect response
    3. Browser makes HTTP GET request (possibly including an id that is related to the submitted data in the query string)
    4. Server responds with a 200 response and the information