I am trying to insert some datas into database table on form submit like this:
function form_example_submit($form, &$form_state) {
if ($form_state['values']['select']=='1') $gender = 'male';
else $gender = 'female';
db_insert('form_pokus_table''form_example_table')->fields(array(
'name' => $form_state['values']['name'],
'gender' => $gender,
'message' => $form_state['values']['message'],
))->execute();
drupal_set_message("Message is successfully saved");
return $form;
}
My schema in .install file looks like this:
function form_example_schema() {
$schema['form_example_table'] = array(
'description' => 'Table for form_pokus module',
'fields' => array(
'id' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
'name' => array('type' => 'varchar','length' => 30, 'not null' => TRUE, 'default' => ''),
'gender' => array('type' => 'varchar','length' => 30, 'not null' => TRUE, 'default' => ''),
'message' => array('type' => 'text', 'not null' => TRUE, 'default' => ''),
'status' => array('type' => 'text', 'not null' => FALSE ),
'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
),
'primary key' => array('id'),
);
return $schema;
}
But nothing happens on form submit, only page is reloaded. What I am mising?