Using drupal_http_post() to submit to external site: What am I doing wrong? I intended to make a module that utilized drupal_http_request with a webform so that the form gets validated before it gets sent to an external url.

I actually was recommended this method over $form['#action'] from a previous inquiry earlier. I did as recommended, thought it worked, but found out that I was mistaken.

I did some troubleshooting and concluded my module is the culprit since:


The module utilizing $form['#action'] had no problems posting to our external url/web app and another external site/service for testing HTTP POST submissions (http://requestb.in)
The module utilizing drupal_http_post could neither post to our external url/web app nor requestb.in


My setup uses the following:


Drupal 6.x
Webform 6.x-3.17


My custom module contains the following code.

function webform_to_data_repo_form_submit(&amp;$form, &amp;$form_state, $form_id) {
    if ($form_id == 'webform_client_form_765') {
        $url = 'external.url.goes.here';
    $headers = array(
                 'Content-Type' =&gt; 'application/x-www-form-urlencoded',
               );

$response = drupal_http_request($url, $headers, 'POST', http_build_query($form_state['values'], '', '&amp;'));
   }
}


Is there something wrong with my module? Just wanted to make it post to some external URL.
Thank you everyone for the pointers.

I realized that my custom module that uses the webform module to submit to an external url (via drupal_http_request) had to be written as two separate functions: one using hook_form_alter and one using a custom submit handler. The code is as follows.

&lt;?php

function webform_to_data_repo_form_alter(&amp;$form, &amp;$form_state, $form_id) {

//I only want form 765 to submit externally //
if ($form_id == 'webform_client_form_765') {
$form['#submit'][] = 'my_additional_submit_handler';
 }
}

function my_additional_submit_handler(&amp;$form, &amp;$form_state) {

$url = 'your.external.url.here'
$headers = array('Content-Type' =&gt; 'application/x-www-form-urlencoded',);
$response = drupal_http_request($url, $headers, 'POST', http_build_query($form_state['values'], '', '&amp;'));

}




?&gt;


As a side note, I never got to test the result of using dpm($response) using the Devel module as beth suggested.

I'm using a webform (via the webform module) to test. What I wanted to happen are two things.


The webform validates the submission which in turn would keep a log of the submission through Drupal (webform module by default and by design).
Simultaneously submit inputs from #1 to external url.


For the longest time, only #1 is happening and I can't seem to make Devel look into $response because that variable only exists when there's an attempt on submission. How does one make Devel module load when a successful submission has been made through a Webform? I guess this is another question for another time.