Do, your script has zero access to Joomla/CB API and of course zero access to "$this". It is a HTML request to that file and that file has no access to anything from the calling site. The only way the above would work is if for example it included the file then return the results, which is not what the integration does.
Being just database queries however you maybe able to do this using the SQL Actions plugin to perform the queries or do as I've suggested earlier and pass variables to your script either in GET or in POST then retrieve and use those variables. You will need to manually create a connection to your database. All of which is without Joomla/CB API and done in pure PHP. You could include Joomlas API I believe though into your script file (if it's on a server with Joomla) and you should then be able to use the API.
Code:
$oDB = mysql_connect( 'mysql_server', 'mysql_user', 'mysql_password' );
mysql_select_db( 'mysql_database', $oDB );
$sql = 'INSERT INTO #__enmasse_sales_person(name,user_name,address,phone,email,zip_code,city,country,published,created_at,updated_at)
VALUE(
"' . $_POST['name'] . '",
"' . $_POST['username'] . '",
"' . $_POST['cb_address'] . '",
"' . $_POST['cb_phone'] . '",
"' . $_POST['email'] . '",
"' . $_POST['cb_zipcode'] . '",
"' . $_POST['cb_city'] . '",
"' . $_POST['cb_country'] . '",
"1",
"' . date("Y-m-d H:i:s") . '",
"' . date("Y-m-d H:i:s") . '"
)
';
//echo $sql; die;
mysql_query($sql,$oDB);
$salesId = mysql_insert_id();
'" . date("Y-m-d H:i:s") . "',
'" . date("Y-m-d H:i:s") . "'
)
//Setup Branch for Merchant
$arrBranches = array();
$arrBranches['branch1']['branchname'] = 'branch1';
$arrBranches['branch1']['name'] = $_POST['name'];
$arrBranches['branch1']['description'] = '';
$arrBranches['branch1']['google_map_width'] = '200';
$arrBranches['branch1']['google_map_height'] = '200';
$arrBranches['branch1']['address'] = $_POST['cb_address'];
$arrBranches['branch1']['telephone'] = $_POST['cb_phone'];
$arrBranches['branch1']['fax'] = $_POST['cb_fax'];
$arrBranches['branch1']['google_map_lat'] = '';
$arrBranches['branch1']['google_map_long'] = '';
$arrBranches['branch1']['google_map_zoom'] = '';
$jsonBranches = json_encode($arrBranches);
//echo '<pre>'; print_r($jsonBranches); echo '</pre>';
$sqlMerchant = "INSERT INTO #__enmasse_merchant_branch(name,user_name,sales_person_id,branches,zip_code,city,country,published,created_at,updated_at)
VALUE(
'" . $_POST['name'] . "',
'" . $_POST['username'] . "',
'" . $salesId . "',
'" . $jsonBranches . "',
'" . $_POST['cb_zipcode'] . "',
'" . $_POST['cb_city'] . "',
'" . $_POST['cb_country'] . "',
'1',
";
//echo $sqlMerchant; die;
mysql_query($sqlMerchant,$oDB);
mysql_close($oDB);
Please keep in mind the above is just an example and of course would need changes. You also would need to ensure the method used is POST and you send those post variables.