I have:
page1
: submits a form
page2
: validates it and and returns a page
Now when I click the back button, it does not go to page-1 instead it comes with a "Confirm form resubmission" window.
How do I prevent this? Based on this answer, I see this as a recommended approach:
This is a common technique on forums. Form on Page1 posts the data to Page2, Page2 processes the data and does what needs to be done, and then it does a HTTP redirect on itself. This way the last "action" the browser remembers is a simple GET on page2, so the form is not being resubmitted upon F5.
But I'm confused. Where should I append my redirects? My page2
view looks like this:
@app.route('/StartPage',method='POST')
def test():
username = request.forms.get('username')
password = request.forms.get('password')
return template('StartPage',search_string=search_string,\
username=username, \
session_id=ses_id)
To follow the POST-Redirect-GET pattern, your POST
route shouldn't return a template.
If it can successfully process the form data, it should afterwards redirect to some sort of success/next page.
If there's a validation error, it should redirect back to the form, perhaps with the error details included in a query string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With