I have two forms, and so two different submit buttons, for one page (page used for adding staff members to company db).
The first submit deals with submitting a username (name and faculty automatically filled in through a command line program). Obviously, I want to keep this information and display it to the user while they are filling out the information required in the second form. This works fine.
The problem is if there is an error in the second form. The addition fails and an error message displays but all the information from the first form is wiped out.
The session variables below are set if the first form is submitted (with no errors):
$_SESSION['name'] = $info['displayName'];
$_SESSION['faculty'] = $info['ou'];
$ownerId = trim(mysql_prep($_POST['ownerId']));
$_SESSION['ownerId'] = $ownerId;
But when these variables are wiped out if the second form is submitted. My understanding is that this happens because the first form is not technically submitted anymore. But, then again, isn’t that the point of session variables — not to be wiped out?
EDIT: Maybe it would be helpful to add that I unset all the session variables, but ONLY if the second form was submitted with no errors. Although I don’t think this is very relevant
There are 2 approaches I could think of
I used to put an hidden field in my form to store the name of the form. Some use the name of the submit button.
The other approach is repopulate the other form which am still thinking of how to do it without using one button for the two form
That is the idea. I just got this from upstair, not tested. In the first form, the previous value is re-populated by the values duplicated in the hidden fields of the second form
Good Luck