I have several stages to an application process consisting of multiple forms on different pages.
I have created a session to handle the data.
My question is, without explicitly stipulating every form field form can i add the form post to an individual part of the session array one by one.
So that when im at the end i can just loop through and print?
Sure, you could do something like this:
This will save all the POST data into the
$_SESSION['form']array. Note that it saves all the data, a malicious user can just add values to this.On the last page you can echo the fields like this (don’t forget to escape the values, that’s what
htmlspecialchars()is for).Edit: The
array_merge()approach is acutaly more elegant than this one, so just forget about the first piece of code.