I am trying to pass variables from a webform page to its redirect URL, but am having no success. Can anyone point me to an example of how to specify a variable on the redirected page?

Here's what I've got so far:

1. Added a webform to the site -- works fine, as a stand-alone contact form.

2. Selected "Redirect POST Values" in order to pass variables to the redirect URL.

3. Viewed the HTML source code for the contact page, in order to locate the ID number for one of the form fields.

4. Selected an input format of "PHP code" on the redirected page.

5. Added simple PHP code on the redirected page -- actually tried about 20 different variations -- but here's one example:

<?php

if ($form_values['submitted']['1175003009']) {

  print "Wow!";

}

?>

6. Entered info on the contact form and submitted, but still no joy . . .

Is there a working example somewhere that I can take a look at?

Comments

tcochran’s picture

*Bump*

So nobody knows how to pass variables from a webform page to a redirect URL?

C'mon, somebody must have tested this, when the new feature was added, right?

Anybody?

amarengo’s picture

Use:

$b=$_POST['submitted']['1175003009'];
print $b;

;)

incom’s picture

Can you post a full working example - thanks

keesje’s picture

$_POST, even $_REQUEST does not contain any submitted variable. I put the PHP code in a node, not in a separate PHP document. This might make a difference. Nonetheless, It should work while redirecting to a node. And it doesn't.

Bug??

edit: beats me, I unchecked 'Redirect POST Values', saved, checked again, saved, and it's working now. Strange.

kcolwell’s picture

Hi,

I've never tried redirecting post values to a node however if you setup just a php file in your themes directory you should be able to access the variables.

In redirect url: http://www.yoursite.com/sites/all/themes/your_theme/form_processor.php

Then put the following in form_processor.php

print"testing: <pre>";
var_dump($_POST);
print"</pre>";

Oh.. and don't forget to check the "Redirect POST Values" box inside "Advanced Settings"

edwbaker’s picture

If you are expecting the variable 'x' then you need to get:

$_POST['submitted']['x']