Hey im completely new to working with drupal, and i ran into a problem regarding storing the data a user have just submitted.

ive got my db table like this:

$schema['medarbejderkartotek'] = array(
  'description' => 'TODO: please describe this table!',
  'fields' => array(
    'medarbejde_ID' => array(
      'description' => 'TODO: please describe this field!',
      'type' => 'serial',
      'not null' => TRUE,
    ),
    'Navn' => array(
      'description' => 'TODO: please describe this field!',
      'type' => 'text',
      'not null' => TRUE,
    ),
  ),
  'unique keys' => array(
    'ID' => array('medarbejde_ID')
  ),
);

my form like this :

function sagsstyring_opret_medarbejder($form, &$form_state) {
  $form['Medarbejder_navn']=array(
    '#title'=> t('Indtast medarbejders navn'),
    '#type'=> 'textfield',
    '#required' => TRUE,  
    '#maxlength'=> 40,
          
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Opret'),
  ); 
    
return $form;
}

and my question is then, how my submit should be, in order to get the user input stored in the database ?

function sagsstyring_opret_medarbejder_submit($form, &$form_state) {
 db_insert('medarbejderkartotek')

    -> fields(array(
      'Navn' => 'Medarbejder_navn',
    ))
   ->execute();

This is what i get, but obvisly its only inserting the 'Medarbejder_navn' into the database.
regards Mics

Any help here would be appreciated

Comments

Drave Robber’s picture

function sagsstyring_opret_medarbejder_submit($form, &$form_state) {
 db_insert('medarbejderkartotek')
    -> fields(array(
      'Navn' => $form_state['values']['Medarbejder_navn'],
    ))
   ->execute();
}
mics’s picture

thanks a bunch mate, you just made my day !

Drave Robber’s picture

You're welcome; also, this should have been in Module Development and Code Questions - it might well have gone unnoticed.