I did some research about using drupal_goto('page'), and I noticed that the parameters of the function can be only the path of the destination page.

I want to use this function in a form submission handler. Can I take the submitted values and use them with drupal_goto() as in the following code?

function my_module_form_submit($form, &$form_state) {
  $database_name = $form_state['values']['databasename'];
  drupal_goto('page', $database_name);

1 Answer 1


In a form submission handler, there is no need to use drupal_goto(), and it should be avoided, since it stops the other form submission handlers from being called.

If you need to redirect the users to a page, you should use $form_state['redirect'], which accepts the same parameters used by drupal_goto(). In particular, the following code will redirect the users to node/123?foo=bar#baz, if other modules don't alter the redirection, and other conditions are met.

$form_state['redirect'] = array(
    'query' => array(
      'foo' => 'bar',
    'fragment' => 'baz',

As for passing the values contained in the array $array to the redirection URL, that is easily done with the following code.

$form_state['redirect'] = array(
  // Se the values you need.

$form_state['redirect']['query'] = drupal_get_query_parameters($array, array());

If then the need is just to pass data from a page to another, there are better solutions, such as passing the data into the session data. I would rather use that, since theoretically there isn't a limit to that data stored as session data, while a URL cannot be longer than X characters.


  • Thenk for your answer but I still need to send an array from the first page to the second page with the use of $form_state['redirect'] Nov 18, 2013 at 16:50
  • Do you need the next page to have access to php data from the prior page? if so, you may need to look into $_SESSION variables.
    – Jimajamma
    Nov 18, 2013 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.