biggieuk Posted April 5, 2010 Share Posted April 5, 2010 Hi all, I have a fairly large form of around 50 textboxes, checkboxes & radio buttons. Each form section is broken up into sections for instance: Contact Name Position Address .... For each section I have named the name tag of each like so: name="contact[name]" This is so that I can handle the $_POST data in arrays. My question is, what would be the best database structure for this? A collegue suggested using serialized arrays? I don't want to have to create a database field for each item on the form but I need to be able to retreive this data based on a userid also. Thanks for any help/ guidance with this. Quote Link to comment https://forums.phpfreaks.com/topic/197684-storing-large-form-data-in-mysql/ Share on other sites More sharing options...
freakstyle Posted April 6, 2010 Share Posted April 6, 2010 There's no right or wrong way here. If you want to make less upkeep, serializing the data is helpful as you can handle it dynamically. In this, you should keep a set of static fields that are always going to exist, first_name, last_name, email_address, address, city, state, postal_code. Then serialize the rest of the data that is more meta data to that user. Don't forget to make sure you validate any form data before saving it into the database, automation is nice but it should not come before security. Also if you are serializing data keep in mind that you can't do pull users up by that information. like, get all users who checked this box. In order to achieve that you would need to get a result of all the users then check for that data through iteration. How i approach this is having a user table with those basic fields i mentioned and a profile table which has the full fields. cheers. Quote Link to comment https://forums.phpfreaks.com/topic/197684-storing-large-form-data-in-mysql/#findComment-1038071 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.