form confirmation before submit to mysql
I have worked on very large form and it’s submitting results to mysql very well. But I want to show confirmation of the entered form data so users can update it if there are any changes required before submitting it to mysql.
What should I use to achieve this? $_PO开发者_StackOverflowST
or $_SESSION
? Please let me know your suggestions.
Definitely $_POST is the choice as it will not required to store again in sessions. Just show the confirmation, if user selects yes, then you can insert them from the $_POST variable which you already have stored.
A combination of both?
When the user submits the form, use $_POST to get the parameters and prolly some validation if you don't let javascript do it for you.
Display those parameters in another page together with the confirm button.
You can keep the input in the $_SESSION for a while and when the user confirms, send it to mysql.
You should use JAVASCRIPT
validation for check validation of this form and if all fields having valid values then Submmit form via POST
method.Now you will get all your fields in $_POST
.
Thanks.
use POST for the non-cookie, non-javascript solution
the confirm page will have the previous form data in hidden field and the data will be submitted again with the Yes button
here is a simple sample using jquery http://jsfiddle.net/robx/QBt5L/. Not formatted for anything, but you can get an idea from it, plus as mentioned, you should also consider JQuery validation for form validating to increase error submissions in required fields.
精彩评论