<?php require_once('../Connections/spectrum.php'); ?>
<?php include_once "../mainfile.php"; //load the global vars and functions
echo "<pre>".print_r($_POST, true)."</pre>";
if (isset($_POST['submit'])){
//run one script
$id = saveNameData();
//run the second script
saveContactData($id);
echo "all saved";
} else {
header ('Location: index.html');
}
function saveNameData(){
$query = "Insert into spec_client set name=".clean($_POST['name']).", address1=".clean($_POST['address1']).", address2=".clean($_POST['address2']).", city=".clean($_POST['city']).", state=".clean($_POST['state']).", zip=".clean($_POST['zip']).", salesrepid=".clean($_POST['salesrepid']).", billingsendto=".clean($_POST['billingsendto']).", billingaddress1=".clean($_POST['billingaddress1']).", billingaddress2=".clean($_POST['billingaddress2']).", billingcity=".clean($_POST['billingcity']).", billingstate=".clean($_POST['billingstate']).", billingzip=".clean($_POST['billingzip']).", billingnotes=".clean($_POST['billingnotes']).", accountsname=".clean($_POST['accountsname']).", accountsphone=".clean($_POST['accountsphone']).", accountsemail=".clean($_POST['accountsemail']).", accountsfax=".clean($_POST['accountsfax']).", accountssecname=".clean($_POST['accountssecname']).", accountssecphone=".clean($_POST['accountssecphone']).", accountssecemail=".clean($_POST['accountssecemail']).", accountssecfax=".clean($_POST['accountssecfax']).", accountsnotes=".clean($_POST['accountsnotes']).", officelocationcity=".clean($_POST['officelocationcity']).", officelocationstate=".clean($_POST['officelocationstate']).", officelocationnotes=".clean($_POST['officelocationnotes']).", bookingonfile=".clean($_POST['bookingonfile']).", bookingagreeneed=".clean($_POST['bookingagreeneed']).", bookingsendto=".clean($_POST['bookingsendto']).", bookingemail=".clean($_POST['bookingemail']).", bookingfax=".clean($_POST['bookingfax']).", bookingnotes=".clean($_POST['bookingnotes']).", relationshipnotes=".clean($_POST['relationshipnotes']).", discountpublic=".clean($_POST['discountpublic']).", discountprivate=".clean($_POST['discountprivate']).", discounteclass=".clean($_POST['discounteclass']).", discountnotes=".clean($_POST['discountnotes']).", additionalnotes=".clean($_POST['additionalnotes']);
mysql_select_db($database_spectrum, $spectrum) or die(mysql_error());
mysql_query($query) or die(mysql_error());
return mysql_insert_id();
}
function saveContactData($id=NULL){
if(empty($id)) die("No foreign key");
$query = "Insert into spec_contacts set companyid=$id, firstname=".clean($_POST['firstname']).", lastname=".clean($_POST['lastname']).", address1=".clean($_POST['c_address1']).", address2=".clean($_POST['c_address2']).", city=".clean($_POST['c_city']).", state=".clean($_POST['c_state']).", zip=".clean($_POST['c_zip']).", notes=".clean($_POST['c_notes']);
mysql_select_db($database_spectrum, $spectrum) or die(mysql_error());
mysql_query($query) or die(mysql_error());
}
function clean($data){
$f = function_exists('mysql_real_escape_string') ? 'mysql_real_escape_string' : 'mysql_escape_string';
return "'".$f($data)."'";
}
?>