Edit php code on a webform
I don't have the exact answer to your question but I can give you some advices to how you can do.

First option, UI way, You can try the "Rules" Module with "Webform Rules" Module.
It gives you the ability to do some operations on given context.
I don't know that module, but it seems to be the easiest solution.



Second option, Dev way, you can manually hook your webform and add php code.
You have to implement the "hook_form_FORM_ID_alter" hook
You can retrieve webform form_id by following this answer of this post.
In your hook implementation, add your custom submit function like the following snippet :

function YOUR_MODULE_form_FORM_ID_alter(&amp;$form, &amp;$form_state, $form_id) {
    if(isset($form['#submit'])){
        $form['#submit'][] = 'your_custom_function';
    }
    else{
        $form['#submit'] = array('your_custom_function');
    }
}




Some usefull links :


Drupal : Form API
Drupal : hook_form_FORM_ID_alter
Module : Webform Rules
Module : Rules