Why can't I save a value from my form? I have a problem with my module that only creates a form to submit a validation.
The target of this module is to set a variable that I put in a textfield.
The problem is that it doesn't save the variable, it only shows the default value. (I use variable_set and variable_get)

This variable is necessary because I use this form in another module that get this variable from the database. (My variable is id_event)

This is my code of my own module:

&lt;?php
function example_form_form1(){
    $form['id_event'] = array(
     '#type' =&gt; 'textfield',
     '#title' =&gt; t('Id Event'),
     '#required' =&gt; TRUE,
         '#value' =&gt; variable_get('id_event', 7), //Here is my dude
    );

    $form['submit'] = array(
     '#type' =&gt; 'submit',
     '#value' =&gt; t('enviar'),
    );
 return $form;
}

function example_form_submit($form, $form_state){
    $id_event = $form_state['values']['id_event'];
        variable_set('id_event', $id_event);//here is my dude
        drupal_set_message($id_event);
}
?&gt;


Now, this variable is necesary for other module that only get.

&lt;?php
$file_json = $this-&gt;options['xml_file'].variable_get('id_event', 1);
//Here don't get the value that i put, only put the value for default.
?&gt;


Thanks :D
The reason your current code isn't working is because your submit handler doesn't follow the correct naming convention (i.e. FORM_FUNCTION_NAME_submit) and you don't explicitly attach the submit handler to the form anywhere so it's not being run.

You can solve this by simply changing the nameof your submit handler:

function example_form_form1_submit($form, $form_state){


Or you could look at system_settings_form() which automates much of this process for you.