Community & Support

Passing parameter from form to a script

I need to pass $value from a form to a script.
So I try with the following lines in the _submit part of the form.

$par = 'node/167/?=' . $value;
return $par;

And in the script which shall receive $value I try with

$param = $HTTP_SERVER_VARS['QUERY_STRING'];

But the script receives nothing! The browser window displays:
http://......./?q=node/167/%3F%3D26
showing that the passed value = 26, correct, but as I said, the script
receives nothing. What am I doing wrong?

Comments

in drupal we usually use

in drupal we usually use 'arg' to catch the values

$param = arg()

in your case try:
$param = arg(2)

some info here
http://drupal.org/node/40385

it worked!

$param = arg(2)

Thanks erle, you saved my day!

...

http://......./?q=node/167/%3F%3D26
showing that the passed value = 26, correct, but

No, it's not "correct". Drupal escapes the "?" (it turns it into "%3F"), thus preventing the server from seeing any "query string" there.

$par = 'node/167/?=' . $value;
return $par;

You need to do:

return array('node/167', $value);

When you return array from submit, drupal treats it as parameters for drupal_goto. The second parameter is the query string.

Does anybody know why the following URL doens't work?
http://api.drupal.org/api/5/function/drupal_goto

nobody click here