Adding form results to a database table?

General project discussion. NOT for help questions.
Post Reply
jayp70
Forum Members
Forum Members
Posts: 11
Joined: Thu Apr 26, 2007 4:09 pm

Adding form results to a database table?

Post by jayp70 »

Is it possible to use Form Builder to create a form then save the results to a database table of your choice?

I've created a database table with 4 fields, then used Formbuilder so when I submit the form the results get saved in this table?
Coldman
Power Poster
Power Poster
Posts: 318
Joined: Sun Jun 22, 2008 5:33 am

Re: Adding form results to a database table?

Post by Coldman »

Read Help for FormBuilder

Code: Select all

*Store Results in Database. This will store the form contents in an internal database. You will always use this disposition if you use the form with FormBrowser.
Important Code of Conduct
Why don't use CMSMS Docs or search?
Do you read Help?
Admin for Swedish Translations Team
Moderator Swedish Forum
After your problem is solved, push the green button
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm
Location: the Netherlands

Re: Adding form results to a database table?

Post by Dee »

Coldman wrote: Read Help for FormBuilder

Code: Select all

*Store Results in Database. This will store the form contents in an internal database. You will always use this disposition if you use the form with FormBrowser.
That was my first reaction too but I deleted it :) The thing is that stores the result in the database for use by the FormBrowser module, not in a table by choice.

The solution would be something like adding a field with type:
*Call A User Defined Tag With the Form Results
and creating an UDT looking something like this:

Code: Select all

global $gCms;
$db =& $gCms->GetDb();

$query = "INSERT INTO test (name, birthdate, email) VALUES ({$param['name']}, {$param['birthdate']}, {$param['email']})";

$db->Execute($query);
However I'm not getting this to work at the moment, in the called UDT there is no parameter $param available as is said in the module help:
*Call a User Defined Tag With the Form Results. This submits all the form results to the User-Defined Tag you specify. The UDT can handle the results however it wants. Values are passed as $param['field_name'].
Kind regards,
D
Coldman
Power Poster
Power Poster
Posts: 318
Joined: Sun Jun 22, 2008 5:33 am

Re: Adding form results to a database table?

Post by Coldman »

Dee wrote:

Code: Select all

global $gCms;
$db =& $gCms->GetDb();

$query = "INSERT INTO test (name, birthdate, email) VALUES ({$param['name']}, {$param['birthdate']}, {$param['email']})";

$db->Execute($query);

I think it should be $params

/Coldman
Important Code of Conduct
Why don't use CMSMS Docs or search?
Do you read Help?
Admin for Swedish Translations Team
Moderator Swedish Forum
After your problem is solved, push the green button
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm
Location: the Netherlands

Re: Adding form results to a database table?

Post by Dee »

Coldman wrote: I think it should be $params

/Coldman
Correct it's a typo in the help, they are assigned as $params['Field Name']

Regards,
D
Coldman
Power Poster
Power Poster
Posts: 318
Joined: Sun Jun 22, 2008 5:33 am

Re: Adding form results to a database table?

Post by Coldman »

btw Dee you have right about this.
UDT is the answer to his question and I'm man enough to admit my error ;).

/Coldman
Important Code of Conduct
Why don't use CMSMS Docs or search?
Do you read Help?
Admin for Swedish Translations Team
Moderator Swedish Forum
After your problem is solved, push the green button
Post Reply

Return to “General Discussion”