In my database I have two tables. One table stores all of the account information, the other table stores all of the user information. Table 1 account_id - is the primary key and is unique to each account Table 2 user_id - is the primary key and is unique to each user account_id - will be set to whatever the account id is in Table 1 You are suggesting that when they click "Enter another user for this account" that I save the account/user information to the database and then when the form refreshes have something like: if (!isset($_POST['submit'])) to determine if this is a continuance of a multiple user submission? And then I should select the account_id that was just created? Using something like: SELECT scope_identity() FROM accounts Or is there a better way to determine the recently created account_id so I can use it for any other user data that is created for this account? On 3/20/07, Greg Beaver <cellog@xxxxxxx> wrote:
Dan Shirah wrote: > Looking for some direction here. > > I have a form that collects user data. When an employee opens the form > they enter in all of the user data for an account, however the account can > have multiple users so the employee has the option to "Enter another user > for this account" and they can do this for as many users as the account > holds. > > What I can't figure out is how to store the first set of user details, have > the blank form come up again, store the second set of user details, have > the > blank for come up again, insert a third set of details and then have all > three sets submit to the database at the same time. > > Did the make sense? > > Would using a session work to store all this user data for a single > submission? Hi Dan, Although sessions look appealing, you may find that users use the "Back" button on their browser to return to the previous step, and sessions won't allow this to work properly. If you really wish to wait until the third user before saving any of them, then I would use hidden form fields with the data from the previous entries. However, if I were in your shoes, I would probably set up the form to create the account and save immediately to the database, then add the other users one at a time. The end of a request is the perfect time to save data, as long as you allow editing of the details. Again, expect users to use "Back" and make sure that if you do save using a numeric primary key, that you pre-generate it so that it will still be present if the user clicks "Back." This way, you can safely allow editing of the data by just using an UPDATE query rather than INSERT if the data already exists. Also, if you are taking sensitive data, be sure this web form is either on a firewalled intranet or some other security precautions so that you don't expose SSNs to the public hacker community. Hope this helps, Greg -- Experience the revolution, buy the PEAR Installer Manifesto http://www.packtpub.com/book/PEAR-installer