/ Published in: PHP
I made this function to render hidden form elements in a new page based on what was sent from the last form. This function can be used to preserve input from a long multiple-page form.
What does it do:
- Go through all the submitted POST elements.
- Draw a loop of those POST elements into this new form (in form of hidden elements).
- When that form submits, previous page's input is included inside this new form's submit action.
Note: Do not use the same form element name as it overwrites as it goes along.
Expand |
Embed | Plain Text
function retain_post_data() { foreach($_POST as $key=>$index) { $form .= "<input name='$key' type='hidden' value='".$index."' />"; } else { foreach($index as $key2=>$index2) { if ($index2 != "") $form .= "<input name='".$key."[".$key2."]' type='hidden' value='$index2' />"; } } } return $form;}
You need to login to post a comment.
