Form refreshes when redirected from header
I have a registration form. The form submits the information to the script (on another page) using POST method. The script checks the various fields to ensure it's being given the required information. If the information is wrong or incomplete it will send the user back to the registration page with some information in the URL to highlight the fields that were wrong.
The problem I face is that all the fields reset and become empty, forcing the user to input all the information again.
Is there a way to stop the fields refreshing?
You'll probably want to use session variables with the form data, then in each form element you'll need to check if there is a corresponding $_SESSION value for it, and if so, assign it to that form element's value (or make it the selected option in a select element). This points to one advantage of having a form page submit to itself, so that you can simply get the data straight from the $_POST array if you need to redisplay the form, using some branching logic in the script to determine if you are initially displaying the form, redisplaying it because of input errors, or going ahead and processing it and then displaying the results (possibly using a redirect at that point so that the browser refresh will not re-submit the form).
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread