So I have a function having http://link/to/$id as destination link.

It works when I use <a href="?q=mymodule/option/$id">Targeted</a>.

But I need to change it to submit form because I need to pass more than one $id. So, I thought it was good to use drupal_goto() rather than the link option.

drupal_goto('mymodule/option/', $id);

Those are not working. It always go to http://link/mymodule/option without passing $id variable. How do I do this correctly?

  • Welcome to Drupal Answers! So, what is the content of $id, if drupal_goto('mymodule/option/' . $id) doesn't work? I take it is not similar to drupal_goto('node/1') since that would work. – kiamlaluno Nov 17 '15 at 19:07

Assume your url is like in this example:


In that case you can take values of param1 and param2 like so:

$param1 = $_GET['param1'];
$param2 = $_GET['param2'];

You may use this parameter for drupal_goto as

drupal_goto("path_here", array("param1" => $param1, "param2" => $param2));

For Drupal 7:

As YPCrumble says you need to use this code:

drupal_goto("path_here", array("query" => array("param1" => $param1, "param2" => $param2)));

For more details, refer to the API Documentation.

  • Shouldn't this be drupal_goto("path_here", array("query" => array("param1" => $param1, "param2" => $param2)));? It didn't work for me when I didn't specifically include the "query" argument. – YPCrumble Oct 13 '17 at 16:49
  • @YPCrumble this is for Drupal 6, you have Drupal 7? – Adrian Cid Almaguer Oct 13 '17 at 18:04
  • ah I see - thanks for the clarification! Hopefully my comment will help someone with D7 :). – YPCrumble Oct 13 '17 at 18:05
  • @YPCrumble I will edit the answer with your code ;-) – Adrian Cid Almaguer Oct 13 '17 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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