Output form result after form_submit I have custom module, where after form_submit, i do some calculations, and get result of those calculations in a variable.

After i hit "submit", i can output those calculations with drupal_set_message , but i would like to format results (array), and print it bellow the submit button. How can i output resulting variable bellow the form or in the form, after submission ?

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

$a=$b+$c;

// on submit, i would like to print/format $a on the reloaded form page

}


Thanks!
What you want to do is use something like $form_state['temporary'] in your myMod_submit function. Set $form_state['temporary'] = $someValue and rebuild your form. You also want your myMod_form function to have a place holder for your data. When the form is loaded, simply check to see if your temp holder is populated. if it is then you know you have a result and display it.

See code below.

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

    ...

    if(!empty($form_state['temporary'])) {
        $form['results'] = array(
            '#type'     =&gt; 'item',
            '#markup'   =&gt; $form_state['temporary'], 
        );
    }

    return $form;
}

function myMod_submit($form_id, &amp;$form_state) {
     ...

     $results = callSomeFunctionToGetResults();

     $form_state['temporary']   = $results;
     $form_state['rebuild']     = TRUE;

     ...
 }


i omitted all my code that would populated $results but this should get you to where you need to go. 

quick addition here. 

I just realized that you wanted it to go to another page and not the same page. I believe in your myMod_submit function you can use drupal_goto(). pass it a url and also pass it some options. you can then parse out the options as your values in the other page. See drupal_goto. however, i haven't tested this option out.