Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Collect form field data and store to a "database" of some kind
Anyone know of a plugin or other way to store field data from an HTML form to some kind of database, be it a text file or MySQL database? Basically I want to have a form on my site that users can enter a few pieces of information into, submit, and have the data added to a file that continues growing with subsequent form submissions. I wonder if there is even a way to hack the standard comment form to do what I want, but it would be nice to have the flexibility of designing my own form from scratch.
-Andrew
Offline
Re: Collect form field data and store to a "database" of some kind
If you don’t mind setting up an own database table, you can use mem_simple_form + mem_form to create a submit form that saves to a MySQL database table of your own making. You can then set up a new section and use smd_query in the corresponding page template to output the data from your custom database table in a format that you can use (e.g. as comma-separated items for saving as a csv file). It will display in the browser and you can then save that page to your hard disk.
All of that requires getting your hands a little dirty and kind of bypasses many of textpattern’s core features. You might find an all-in-one separate solution such as machform equally good.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Collect form field data and store to a "database" of some kind
Thanks a lot for the info, Jakob. Briefly reading about mem_form / mem_simple_form, they seem to be independent of each other? Really I’m not sure where to start to begin using them. I will do some more reading, but I may end up using something like the machform you suggested for simplicity’s sake. Thanks again.
Offline
Re: Collect form field data and store to a "database" of some kind
mem_simple_form needs mem_form to work. You can think of mem_simple_form as the container and submitter with mem_form for writing the individual form fields, which you’ll need to name in the format “filterprefix_fieldname” as described in the mem_simple_form help. mem_simple_form then takes the data submitted, filters it according to the prefix type you specified and passes it to the right database. You have to set up the database table yourself with phpmyadmin, which is why it is not really a beginners tool.
TXP Builders – finely-crafted code, design and txp
Offline