I have been doing this and basically i paste the php code on end submit text area
Here is a simple and complex code i use for a site to redirect the form based on k2 extra field oon which the form was published.. The form includes a call to joomla framework. Let me know what you may need and will build you a custom code for that. Hope this is a good direction.
require_once("configuration.php");
$conf = new Jconfig ();
$base_url = JURI::root();
$this->execPieceByName('ff_InitLib');
if(isset($_REQUEST['id'])){
$state = JRequest::getVar('state');
$id = JRequest::getVar('id');
// Fetch k2 items extra fields
$f_rows = ff_select("SELECT `extra_fields` FROM `".$conf->dbprefix."k2_items` WHERE `id` =".$id);
$mfields = $f_rows[0];
$dfields = $mfields->extra_fields;
$fields =(array)json_decode($dfields,true);
//Blind Method comented assumed item 2 thus in array position 1 is always the redirection link
if (isset($fields[1])) {
$link = @$fields[1]['value'];
}
$link = addhttp($link);
if (url_exists($link)) {JFactory::getApplication()->redirect($link);}
}// end if isset else go to page 2
//header("location: /index.php?option=com_virtuemart&page=shop.cart");
function addhttp($url) {
if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {
$url = "http://" . $url;
}
return $url;
}
function url_exists($url) {
if (!$fp = curl_init($url)) return false;
return true;
}