Last updated 9 December 2016. Created on 10 October 2009.
Edited by jrockowitz, joetsuihk, tstermitz. Log in to edit this page.

It should be easier to format the confirmation page and capture form entries. Ideally, you would have access to all the form variables, and you could do this in a confirmation-page.tpl.php as well as in the confirmation page window under [webform]:Edit:Configuration. It took me a long time to find this tip on how to access form variables in confirmation pages.

Here is a very simple example to get you started, that I adapted from the above tip. Permit PHP code in your format and insert the following in the confirmation window of your [webform]:Edit:Configuration.

include_once(drupal_get_path('module', 'webform') .'/includes/');
$nid = arg(1); // need to hard-code nid if this is a custom page
$sid = $_GET['sid'];
$submission = webform_get_submission($nid, $sid);

$first_name = $submission->data[6]['value'][0];
$last_name = $submission->data[7]['value'][0];
$thanks = $first_name . " " . $last_name;

<h2>Thank you <?php print $thanks ?>... Your registration has been sent.</h2>

So, in my form I created a Form Component called "Last Name", identified by Field Key "last_name" (See "Edit Component: Advanced settings"). But, if I want to use it in the Confirmation Message block, I need to first get the submission using "node id" and "submission id", which then gives me access to an array of my field:values. Use data[6] ['value'] to address the array to get the first_name.

The difficulty here is that you have to address your form fields numerically. This means you need to get a copy of your form data structure, which is possible using the procedure suggested in "THEMING.TXT" in your webform module folder:

Copy (do not move!) the "webform-mail.tpl.php" file to your theme directory.
To get a better idea of what variables are available to you, you can include the print_r function in your email. Simply include the line [at the bottom of the file]:


to get a listing of all the available fields you can use in your mail.

This will printout (via email of your form submission) both the numeric:value and the field:value data structures of your form that you need to identify your variables. I munged these into excel so I can see at a glance the numeric array, the form component, and a typical value.

Looking for support? Visit the forums, or join #drupal-support in IRC.


shaneforsythe’s picture

Is there anyway to get SID to be linked as hashed value?

Currently if you have a confirmation page as a seperate node, the end user will see something like

A curious user, or nastier hacker can then just manually sort through different numeric sid's and see who else has sumbitted to form and what answers they left. (if you echo out the form details, like say you are provided a screen to print out for their records or something)

jenstechs’s picture

I came across this page while looking for a way to examine form data in the webforms 3 module's confirmation page. Is there any other way to load the node data without that entirely insecure snippet?

GiorgosK’s picture

take a look at comment #14 and #20

cccarlington’s picture

You should just be aware that if you use any type of select field type in the webform
$submission->data[$key]['value'][0] returns the Key for the select and not the "Some Readable Option".

Just make your keys meaningful and you may not have to do too much extra work on your confirmation page.

captcashew’s picture

I had a follow up question. I'm trying to set up a valuation to see if a checkbox button is selected or not. I've been able to figure out the final array to see the value on 4 different checkboxes like so:


But that just checks the value, not if the checkbox is actually checked or not. Is there an easy way to do modify the code above to check on that? Something like this?


I'm sure there is, I just don't know the syntax. Any help would be appreciated. Once I can figure out to target the checked/unchecked, I can figure out the if statement on my own I think.



bartclarkson’s picture

I don't know how others do it, but I use a hidden field in the webform called shown_once (or whatever). So on the confirmation page, check shown_once is false when you load the submission, update the submission node to make it true, and then do whatever with the user information. My latest use case was populating an invisible iframe to integrate a webform submission with a form handler on Pardot.

One other thing. On Boost settings, entered logic for do not cache if isset($_GET['sid']) .

mylesorme’s picture

I've followed this to successfully retrieve submitted values for text fields but not for grid entries:

$q1 = $submission->data[1]['value'][1];

I can verify that webform_submitted_data.cid = 1 and and in the same row has a value stored in it, the number '4'.

I am able to reproduce the above example, it is just the grid data that I can't access.

Any ideas?

christelle41’s picture

The example also works with D7 ! Great !

CanOne’s picture

wasnt to easy to find this solutioin..but its workin like a charm :)

thank you!

jweedman’s picture

This may help someone later down the road. I couldn't get this to work for a while. Every time I submitted a form, I got a PHP Fatal Error: "Call to undefined function webform_get_submission()".

I saw, however, that the author was trying to include this in the first line of the example script:

include_once(drupal_get_path('module', 'webform') .'/includes/');

After doing some more searching, other people had solved the same PHP error with the following include:

include_once(drupal_get_path('module', 'webform') .'/'); 

The issue? The path to "" is different. Maybe it has to do with the module version you're running? I'm on Webform-6.x-2.9. Anyway - removing the 'inludes/' from the path fixed the issue for me. Great example by the way - still saved me a bundle of time! Hope this helps!