Can't insert data to database on form submit I am trying to insert some datas into database table on form submit like this:

function form_example_submit($form, &amp;$form_state) {

    if ($form_state['values']['select']=='1') $gender = 'male';
    else $gender = 'female';

    db_insert('form_example_table')-&gt;fields(array(
      'name'    =&gt; $form_state['values']['name'],
      'gender'  =&gt; $gender,
      'message' =&gt; $form_state['values']['message'],      

    ))-&gt;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' =&gt; 'Table for form_pokus module',
        'fields' =&gt; array(
            'id'        =&gt; array('type' =&gt; 'serial', 'unsigned' =&gt; TRUE, 'not null' =&gt; TRUE),
            'name'      =&gt; array('type' =&gt; 'varchar','length' =&gt; 30,     'not null' =&gt; TRUE, 'default' =&gt; ''),
            'gender'    =&gt; array('type' =&gt; 'varchar','length' =&gt; 30,     'not null' =&gt; TRUE, 'default' =&gt; ''),
            'message'   =&gt; array('type' =&gt; 'text', 'not null' =&gt; TRUE,   'default'  =&gt; ''),
            'status'    =&gt; array('type' =&gt; 'text', 'not null' =&gt; FALSE ),
            'created'   =&gt; array('type' =&gt; 'int',  'not null' =&gt; TRUE,   'default'  =&gt; 0),          
        ),

        'primary key' =&gt; array('id'),

    );

    return $schema;
}


But nothing happens on form submit, only page is reloaded. What I am mising?
your schema

&lt;?php
function form_example_schema() {

    $schema['form_example_table'] = array(
        'description' =&gt; 'Table for form_pokus module',
        'fields' =&gt; array(
            'id'        =&gt; array('type' =&gt; 'serial', 'unsigned' =&gt; TRUE, 'not null' =&gt; TRUE),
            'name'      =&gt; array('type' =&gt; 'varchar','length' =&gt; 30,     'not null' =&gt; TRUE, 'default' =&gt; ''),
            'gender'    =&gt; array('type' =&gt; 'varchar','length' =&gt; 30,     'not null' =&gt; TRUE, 'default' =&gt; ''),
            'message'   =&gt; array('type' =&gt; 'text', 'not null' =&gt; TRUE,   'default'  =&gt; ''),
            'status'    =&gt; array('type' =&gt; 'text', 'not null' =&gt; FALSE ),
            'created'   =&gt; array('type' =&gt; 'int',  'not null' =&gt; TRUE,   'default'  =&gt; 0),          
        ),

        'primary key' =&gt; array('id'),

    );

    return $schema;
}
?&gt;


needs to look like:

function form_example_schema() {

    $schema['form_pokus_table'] = array(
        'description' =&gt; 'Table for form_pokus module',
        'fields' =&gt; array(
            'id'        =&gt; array('type' =&gt; 'serial', 'unsigned' =&gt; TRUE, 'not null' =&gt; TRUE),
            'name'      =&gt; array('type' =&gt; 'varchar','length' =&gt; 30,     'not null' =&gt; TRUE, 'default' =&gt; ''),
            'gender'    =&gt; array('type' =&gt; 'varchar','length' =&gt; 30,     'not null' =&gt; TRUE, 'default' =&gt; ''),
            'message'   =&gt; array('type' =&gt; 'text', 'not null' =&gt; TRUE,   'default'  =&gt; ''),
            'status'    =&gt; array('type' =&gt; 'text', 'not null' =&gt; FALSE ),
            'created'   =&gt; array('type' =&gt; 'int',  'not null' =&gt; TRUE,   'default'  =&gt; 0),          
        ),

        'primary key' =&gt; array('id'),

    );

    return $schema;
}


you had the wrong table name as the schema index.