I have created a PHP form which requires the user to select a postcode from a list of postcode values.
The user presses submit two times:
– once to go to address select menu which will display a select drop-down with values
– second presses “ok” button to select the address corresponding to his postcode value
I need to keep the value of the selected postcode value for when the form gets submitted. I have tried setting up the postcode drop-down value chosen in a SESSION… but it gets lots when user presses form submit.
How can I keep all the form values even after refreshing the page when the user presses one of the submits?
“How can I keep all the form values even after refreshing the page when the user presses one of the submits?”
Reading your question I didn’t understand if each of the form submits actually gets submitted to the server, but I’m going to assume so. I’m also assuming you’re trying to use PHP sessions to accomplish this.
When the user submits the form, save the values server-side in a PHP session
If, after choosing the address, the user gets redirected to the initial form and you want to populate that:
After the final submit you should have all the submitted values saved in the
$_SESSIONarray. Don’t forget to alwayssession_start()before trying to handle anything session related.