I'd like to be able to specify an external URL for the form action (in my case, so I can make a Paypal submission). I already have hand-coded Paypal buttons on my site, that have another window/tab as the target, and it seems to work fine. I have no need to store any of the form data, so perhaps this is adequate for some kinds of forms submitted to some external sites.

There has been an earlier request in v5x, and some discussion in v6.

Comments

Anonymous’s picture

I'd like this functionality too!

I'm making a form that needs to send the user-entered values to an external website. Failing all else, I'll make my own form in PHP, but I like the Webform UI so prefer that, if possible...

quicksketch’s picture

Status: Active » Closed (won't fix)

Webform is a package, not a just a form-building tool. This would be better off as a separate module without all the bells and whistles of Webform (not to mention the significant weight). I'd suggest a super-simple module that uses Form Builder to construct the forms.

Anonymous’s picture

Yes, I suppose that'd be the best option. Looking forward to Form Builder!

uhsarp’s picture

Here's the code to extract all the form data and fields

theme('webform_mail_fields', 0, $form_values['submitted_tree'], $node);

so you can use it like this

------

<SCRIPT LANGUAGE="JavaScript"><!--
setTimeout('document.test.submit()',5000);
//--></SCRIPT>

<form name="test" action="where_you_want_to_send_it.php" method="post">
<input type="hidden" name="data" value="<?php echo theme('webform_mail_fields', 0, $form_values['submitted_tree'], $node); ?>">
<input type="submit" name="submit>
</form>

------

Customize the above code as needed and paste it in the "Additional Processing" field in the webform properties.

jfinkel’s picture

Here is a method that works for me to send the form data on to Paypal.

I used Webform to create the basic form. In my case, I do want the data stored in the database. In the Webform Advanced Settings I added the following code to the Additional Processing

// Create and populate an array for Paypal-specific data
$paypal = array();
$paypal['cmd'] = '_xclick';
$paypal['business'] = 'MY PAYPAL ADDRESS';  // doing this here prevents email harvesting
$paypal['page_style'] = 'Primary';
$paypal['bn'] = 'PP-DonationsBF';
$paypal['item_name'] = 'Donation';
$paypal['currency_code'] = 'USD';
$paypal['no_shipping'] = '1';
$paypal['tax'] = '0';
$paypal['lc'] = 'US';
$paypal['rm'] = '1';
$paypal['return'] = 'http://MY THANK YOU PAGE';
$paypal['cancel_return'] = 'http://MY CANCEL PAGE';

// Append the Paypal data to the $form_values['submitted_tree']
$data = array_merge($form_values['submitted_tree'], $paypal);

// Put the data in a query string
$query = http_build_query($data, '', '&');

// Set the URL to Paypal's processing site and append the query string
$url = 'https://www.paypal.com/cgi-bin/webscr?' .$query;

// Set the webform's confirmation page to Paypal
$node->webform['confirmation'] = $url;

This assumes that there is a webform field named "amount" because that is what Paypal expects.

I could have create all these fields as Webform hidden fields, but then the page would have rendered with an email address (the ['business'] field), which could be harvested by bots. I never put hard-coded email addresses on pages. It's just easier for me to create all the hidden fields in one place.

Anyway, I hope this helps someone.

rdworianyn’s picture

-jfinkel - This is exactly what I was looking for! Great solution to a very common web practice. Your time and effort in sharing this with the community is greatly appreciated!

dmidkiff’s picture

jfinkel-

I think this method would work for me as well. However, I will need to change it to work with linkpoint.
if I add the code just as you have it, the form submits but nothing is redirected.

I am getting this error:
warning: array_merge() [function.array-merge]: Argument #1 is not an array in /myroot/sites/all/modules/webform_php/webform_php.module(82) : eval()'d code on line 18.

same thing on line 21.

I am a novice and any suggestions would be most helpful.

matt b’s picture

re #5 on 6.x-3.2 there is no Additional Processing field. I tried putting this in the confirmation field, but it didn't work. Is there a way of doing this in 6.x-3.2?

matt b’s picture

Now trying this with Webform PHP (http://drupal.org/project/webform_php) but the code snippet in #5 will need tweeking as the data is submitted with no PayPal payment.... I'll post updated Additional Processing code for Webform 3 with PHP here if I figure it out!

geerlingguy’s picture

For those using Webform 3, check out this post, which contains sample code I used with my D7 site to redirect a user to PayPal after completing a webform (thanks partly to code found in this thread):

http://www.midwesternmac.com/blogs/jeff-geerling/integrate-webform-3x-pa...

The Webform Payments module is slated for a D7 release some time, but I haven't heard much since October last year...