tags:

views:

160

answers:

3

I have a few forms who's data needs to be written to the main database in their own tables. Just simple name-email collection forms, that are part of regular pages in drupal. I suspect the right way to do this would be to write a module that would have the query in a function, but this is just a guess. I've never written a module before, and don't know how the form would be processed that way.

It's also a guess that to perform the db query within a node would be insecure?

The only other idea I have would be to use a php file on the server to do the form processing, with the db query written there, but that seems very non-drupal, as far as I can tell.

How to??

+2  A: 

http://drupal.org/node/508 is Drupal's info on module development

You'll be wanting to use the function "db_query()"

You can use Drupal's built in methods to build forms though that will save the data for you. Have a look at the module developers guide though and you should be able to figure it out. Module development sounds intimidating but it's not as hectic as it seems once you actually know what's going on with Drupal (hence, read the guide).

j3frea
A: 

Have you checked what's already out there? Webform may be able to solve your needs without any custom code.

Also, I highly recommend the book Pro Drupal Development if you want to learn more about Drupal and basic module development.

Eli
A: 

I'd second the Webform module. Create a really simple webform with name and email (results can be emailed or stored automatically in the DB, and can be exported easily in several formats). Then check out http://drupal.org/project/webformblock to put that webform in a block and place wherever you need it on your site. No custom coding required!

Jason

jpamental

related questions