I was wondering what is the best practice to deal with form processing?
In my case I do something like that:
- if the user hasn't submited the form
- display the form
- else
- if there are form errors
- display errors
- display form again
- else
- display a success message
- (and) display the form again
- if there are form errors
My problem is that I'm repeating the HTML code for the form for 3 times and I don't think this is a good practice (long file, difficult to read).
Look, it's as simple as an egg!
Just put the same actions in the different order:
If you can't live without a success message (a quite useless thing in my opinion) you can display it using get parameter (less preferred) or session (optimal)
oops! it was an old one.