I have a database that has two tables, one of which contains a foreign key back to the first. Similar to this:
Table1
id
description
some
other
information
Table2
table1ID
Some
other
information
For each table1 there can be any number of entries in table2. I need to create a form that allows users to insert new items into tables 1 and 2. I've run into this issue in a number of projects. In one, it's saving role playing game stats. Table1 is the vehicles table and Table2 holds information on each of the vehicle's weapons.
I can think of two ways to handle this. One is to show all the information in one form, and use Javascript to allow users to add new sub-forms for each weapon as they need them. Then process it all at once. However, this is a little ugly and, obviously, relies on javascript. So it's not friendly to those who have javascript turned off.
The other way I can think of, would be to have multiple pages. The first page would allow the user to enter general data, then they could hit next to enter weapon data. Each time they hit next, they could enter a new weapon. Finally the fully entered vehicle would be displayed to them and they would be able to go back and edit each part of it as they so choose and, when they were ready, submit it.
On the one hand, this way requires a lot more processing than the first. It is much more involved. It would require that each step of the vehicle's creation be added to the database for temporary storage while the user worked on it. It would have to be marked as incomplete. I would have to create some sort of cron job to clean out all the incomplete vehicles.
On the other hand it uses no javascript.
Are there other ways of handling situations like this? If not, which of these two methods is considered the better practice? Is there a way to hang on to the data between form pages in the second method with out temporarily adding it to the db?
The tools I have available to me are a MySQL database, PHP, javascript, html/css (obviously), and a linux operating system.