I am using PHP to write data to a MySQL database. A user should fillout up-to 3 separate forms. How do I save this information in the database in 3 different tables. Is my question clear?

Do I use sessions? Do I use cookies?  Is there another alternative?  

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

azzkikrConnect With a Mentor Commented:
Hey diverdiver,

If I understood you correctly you are talking about consequently filled forms, a survey in other words.
Usually when one requires a user to fill three consequent forms he will need all three filled out, so there is no point to store each one separately to the database.
On the other hand, storing the data entered in the session object isn't a good idea, because they usually should be kept relatively small, especially on heavily loaded sites, otherwise you'll end up with your server engine consuming too much memory or constantly serializing the session objects. Keeping this data in session may worth it in only rare case when you require disconnected user to continue his survey.
So, I think the best way is to pass the data in the hidden fields. It will require more network traffic from and to client, but it is simple and reliable.

Hope this helps,
What do you mean at "A user should fillout up-to 3 separate forms"?
diverdiverAuthor Commented:
Yes a user most fill out up to 3 forms. I had to separate it into three forms as there is a lot of information that needs to be filled out by the user.

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

So does my comment answer your question then? ;)

if your data is just the text data i dont think Session would affect performence  of your system.

session data is stored in the tmp files on the server and you can store upto 2 mb of data

and in ur case if its just text data then it shld be arnd 2-3 kb.. so shld affect performence at all.

Pass the data from form to form using INPUT TYPE=HIDDEN, and let the final form insert it all into database(s).
All Courses

From novice to tech pro — start learning today.