php - What is right method to repopulate field values after submit.? -
I'm using sessions to recoup values in forms, something looks like my form is a few fields And I want to populate the user values have been entered after separating side validation. The form below is:
& lt; Html & gt; & Lt; Form & gt; Name: & lt; Input type = "text" id = "name" name = "name" value = "& lt; php if (isset ($ _ session ['NAME'])) $ _SESSION ['NAME'] ;; & gt; "& Gt; Address: & lt; Input type = "text" id = "address" name = "address" value = & lt ;? Php if (isset ($ _ session ['ADDRESS'])) $ _SESSION ['ADDRESS'] echo; ? & Gt; & Gt; & Lt; / Form & gt; & Lt; / Html & gt;
I am storing values in the action page like this:
Want to know if this is the right way to do this, to populate the values entered by the user after the server side verification? However it works fine.
There is no need to store it in a session variable if you use it after posting the form is required. You can use either $ _POST or $ _GET, depending on the form submission method you use.
In addition, you can use the field name to post values using the function at $ _POST or $ _GET.
Comments
Post a Comment