Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By mics on
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
function
thanks a bunch mate, you just
thanks a bunch mate, you just made my day !
You're welcome; also, this
You're welcome; also, this should have been in Module Development and Code Questions - it might well have gone unnoticed.