I have a forms.php to get contact data, name, address, etc. Last field is a status line of 72 bytes.
with submit, reset & cancel buttons.
action=update.php method=POST
update.php inserts the data into mysql table, and on success header(Location: www.what.com?status='Record inserted');
the first thing forms does is check if status defined or isset? loads $_POST('status) and if Record inserted clears all data.
try and capture logic goes and gets db error and does similar but leaves data.
I added markdown single back-ticks around the line in your post that the forum thinks looks like markup so that it won’t get parsed by the forum software.
Cannot tell from the description what the implementation is. Post the form and form processing code needed to reproduce the operation to get specific comments.
The redirect upon successful completion of the post method form processing code should be to the exact same URL of the current page to cause a get request for that page. This prevents the browser from trying to resubmit the form data should that page get browsed back to or reloaded.
You should NOT pass values on the end of the URL that determine what result message gets displayed on a page, as this opens your site to phishing attacks.
To display a one-time success message, either store the message text or a flag value in a session variable, before you perform the redirect, then test for this session variable, display the success message, and clear the session variable at the appropriate location in the html document.
For user/validation errors, you should store them in an array using the field name as the array index. At the end of the form processing code, if there are no errors (the array is empty), perform the redirect. If there are errors the code will continue on to (re)display the html document, where you can test for and display the user/validation errors, either all at once or individually adjacent to the field they correspond to, then redisplay the form, populating the field values with the submitted form data, so that the user just needs to correct any errors and can resubmit the form.
Many years ago, more that I want to admit, did the exact same kind of thing with CICS.
firsttime display, and gather the data.
then either success or display errors.
If you are not old like I am: FYI
IBM CICS** (Customer Information Control System)