Form API to Database
Connecting to the database and writing your own SQL, outside of the Drupal framework, while possible will put you in the dark ages. Drupal handles a lot of the heavy lifting and abstraction for you. If you are used to writing your own PHP to do DB queries it can be tempting to go with what you know. but  in the cases where you need to use custom queries use the Drupal DB API  like  Berdir suggested. 

However often there are ways to use forms, without having to write your own database methods. Depending on what you want to do with the data there are several options.

Webform may be what you are after. Which will allow you to create custom forms with simple data management at the back end. Again fairly simple to implement but in this case you won't have the overhead of new nodes and the data is easily exportable.

In both of these cases you can use hook_form_alter to customize the form if you wish.