Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/197684-storing-large-form-data-in-mysql/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.