How to pass variable to a view after submitting? Why does the below code not work?  I am trying to pass the $_POST value to example_page() when I submit the form:

function example_menu () {
  $items['example'] = array(
    'title' =&gt; 'Example',
    'page callback' =&gt; 'drupal_get_form',
    'page_arguments' =&gt; array('example_form'),
    'type' =&gt; MENU_CALLBACK
  );
  return $items;
}

function example_page($arg) {
  return "hello, $arg!";
}

function example_form($form,&amp;$form_state) {
  $form['name'] = array(
    '#type' =&gt; 'text',
    '#default_value' =&gt; t('Enter your name') 
  );
  return $form;
}

function example_form_submit($form,&amp;$form_state) {
  //BELOW DOES NOT WORK, and forget about passing raw HTML to output
  return example_page($form_state['values']['name']);
}
I'm only assuming but I would imagine that the form is redirecting somewhere after your submit handler, that's why the result of example_page is not being displayed. Also I'm not sure if you're copying the code or written it on StackExchange but you're missing a return from your hook_menu

This is how you'd normally pass variables to pages:

function example_menu () {
  $items['example'] = array(
    'title' =&gt; 'Example',
    'page callback' =&gt; 'drupal_get_form',
    'page_arguments' =&gt; array('example_form'),
    'type' =&gt; MENU_CALLBACK
  );

  $items['example/page/%'] = array( // % means variable
    'title' =&gt; 'Example arg',
    'page callback' =&gt; 'example_page',
    'page_arguments' array(2), // 0 is example, 1 is page, 2 is the % variable
    'type' =&gt; MENU_NORMAL_ITEM,    
  );
  return $items;
}

function example_page($arg) {
  return '$arg is: ' . $arg;
}

function example_form($form,&amp;$form_state) {
  $form['name'] = array(
    '#type' =&gt; 'text',
    '#default_value' =&gt; t('Enter your name') 
  );
  return $form;
}

function example_form_submit($form,&amp;$form_state) {
  // No return from submit handler, but set redirect
  $form_state['redirect'] = 'example/page/' . $form_state['values']['name'];
}