How do I store the input value on form submission? I made a simple form in a module with a textfield and a submit button. Every time I type something into the textfield and submit, when the page loads, the default value is in the textfield. I followed the tutorial on http://www.badzilla.co.uk/Drupal-7-Tutorial--Form-Block-With-Template-File

Every #value property is set to whatever I type into the textfield under $form and $form_state except #default_value. 

What am I missing?

Here is the code

&lt;?php

function my_form_block_info() {
  $block = array();

  $block['my_form_block'] = array(
    'info' =&gt; t('My Form'),
    'weight' =&gt; 0
    );
    return $block;
}

function my_form_block_view($delta) {
  $block = array();
  switch ($delta) {
    case 'my_form_block':
      $block['title'] = t('Sample form in block');
      $block['content'] = drupal_get_form('my_form_form');
      break;
  }
  return $block;
}


function my_form_form($form, &amp;$form_state) {
  $form['name'] = array(
    '#title' =&gt; t('Name'),
    '#type' =&gt; 'textfield',
    '#default_value' =&gt; 'some default value',

  );

  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('submit'),
    '#validate' =&gt; array('my_form_validate'),
    '#submit' =&gt; array('my_form_submit'),
  );

  $form['#theme'][] = 'my_form';
  return $form;
}







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

return TRUE;
}



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

    drupal_set_message(t('Hello :name - how are you?', array(':name' =&gt; $form_state['values']['name'])));

    $input = $form_state['input']['name'];
    $form_state['values']['name'] = $input;
}


function my_form_theme() {

    return array(
        'my_form_form' =&gt; array(
            'arguments' =&gt; array('form' =&gt; NULL),
            'render element' =&gt; 'form',
            'template' =&gt; 'my_form',
        ),
    );
}
I would have thought you would be able to do something like this in your form handler...

'#default_value' =&gt; $form_state['post']['name'] ? $form_state['post']['name'] : 'some default value',


...but perhaps since this is in a block, it is being called "fresh" each time the page is displayed.

So, quick and dirty (and possibly all hideously wrong) the following does work...

'#default_value' =&gt; $_SESSION['foo_bar_baz'] ? $_SESSION['foo_bar_baz'] : 'some default value',


...if you put...

 $_SESSION['foo_bar_baz'] = $form_state['values']['name'];


...in your submit handler.  At least for logged in users anyway, and will persist during his/her session.

Hopefully there is a "drupaler" way of doing this, but in the meantime, flame retardant suit on.