Insert form values in the database I am new to Drupal 7, and I am trying to insert the form values in a database table. I used many ways to do that, but I am not getting successful result. What is wrong with the code I am using?

drupal_write_record('formtest', $data);
function form_test_form_submit($form, &amp;$form_state) {
  $id = db_insert('formtest')
    -&gt;fields(array(
      'First name' =&gt; $form_state['values']['firstname'],
      'Lastname' =&gt; $form_state['values']['lastname'],
      'Email' =&gt; $form_state['values']['email'],
      'Password' =&gt; $form_state['values']['password'],
      'Year of birth' =&gt; $form_state['values']['birthdata'],
      'Image' =&gt; $form_state['values']['fileimage'],
  ))
  -&gt;execute();
  drupal_set_message(t('your messagees is added is sucessfule'));
}
Is your submit function getting called to begin with?  Just put a dsm in the beginning of your submit function and make sure it is being called.  If it is, then, dsm your form_state['values'].  If you can see all the values in form_state, then, make sure your table name and column names are spelled exactly the same as they are case-sensitive.