insert webform component values into a custom table i am having trouble storing webform component values into a custom database table,
i have created a custom module to insert the data into the table but its not working and i can't figure out where my problem is can someone please help
here's my code  thanks

&lt;?php 
function customform_form_alter(&amp;$form, $form_state, $form_id) {
    if ($form_id == 'webform_client_form_24') {
        $form['#submit'][] = 'customform_additional_insert';
        if ($node = menu_get_object()) {
            $form['submitted']['node_id']['#value'] =$node-&gt;nid;
            $form['submitted']['amount']['#value'] = @$node-&gt;field_needed_amount['und'][0]['value']; 
            $form['submitted']['full_name']['#value'] = @$node-&gt;title;
            $form['submitted']['image']['#value'] = @$node-&gt;field_student_photo['und'][0]['fid'];  
        }
    }
}

function customform_additional_insert($form, &amp;$form_state) {
    $data = $form['submitted'];

    // Insert a record into a 3rd-party module table when a submission is added.
    db_insert('sponsorship')
        -&gt;fields(array(
            'n_id' =&gt; $form['submitted']['node_id']['#value'],
            'user_id' =&gt; 1,
        ))
        -&gt;execute();
}
?&gt;
I would suggest taking the data straight out of the webforms DB tables.

To understand how to do that we need to look at how data is stored in the DB.

Each time a new webform is created a row for it is created in the webform table. Each webform has a unique identifier called nid.

Each component added to the webform is stored in the webform_component table and has a unique identifier of cid (cid is only unique per webform, nid is also required to make the primary key).

Now when a user fills in the webform a row is created in the webform_submission table (with a unique id of sid) and each fields value is stored in webform_submitted_data. Each row in the webform_submitted_data table has a nid (the webform ID), sid (submission ID) and cid (the component ID).



So, if you wanted to get all of the data from a particular submission with the name of the field (or component), uid and the data submitted you can use the following query:

SELECT c.`name`, sd.`data`, s.uid
FROM webform_submitted_data sd
INNER JOIN webform_component c ON c.cid = sd.cid AND c.nid = sd.nid
INNER JOIN webform_submissions s ON s.sid = sd.sid
WHERE sd.sid = {YOUR SUBMISSION ID}


Or to show all of the values submitted for a particular field with uid and date then you could use:

SELECT sd.`data`, s.uid, s.submitted
FROM webform_submitted_data sd
INNER JOIN webform_component c ON c.cid = sd.cid AND c.nid = sd.nid
INNER JOIN webform_submissions s ON s.sid = sd.sid
WHERE sd.cid = {YOUR COMPONENT ID}