<?php
include 'db_connect.php';

if($_GET['mode']=='insertbml')
{
$sql1="delete from commst where  compid='$_POST[compid]' ;";	
$sql2="INSERT INTO `commst` (`id`,  `compid`, `name`, `address`, `telephone`, `email`) VALUES (NULL,  '$_POST[compid]', '$_POST[name]', '$_POST[address]', '$_POST[telephone]', '$_POST[email]');";

$sql3="delete from vehreg where vehno = '$_POST[vehno]' and compid_key = '$_POST[compid]';";

$sql4="INSERT INTO vehreg set
		vehno = '$_POST[vehno]',
		compid_key = '$_POST[compid]',
		rcno = '$_POST[rcno]',
		chassisno = '$_POST[chasisno]',
		engineno = '$_POST[engineno]',
		mfgyear = '$_POST[mfgyear]',
		make = '$_POST[make]',
		model = '$_POST[model]',
		color = '$_POST[color]',
		vin = '$_POST[vin]',
		variant = '$_POST[variant]',
		vehtype = '$_POST[vehtype]',
		enginetype = '$_POST[enginetype]',
		inscmp = '$_POST[inscmp]',
		policyno = '$_POST[policyno]',
		insexp = '$_POST[insexp]',
		puc = '$_POST[puc]',
		supervisor = '$_POST[loginname]',
		location = '$_POST[cmpcity]',
		runkms = '$_POST[runkms]',
		nextservkms = '$_POST[nextservkms]';";
}

if(!empty($sql1))
{
if(mysqli_query($con,$sql1)&&mysqli_query($con,$sql2)&&mysqli_query($con,$sql3)&&mysqli_query($con,$sql4))
echo "Record Added To Masters";
else
echo "Error: " .mysqli_error($con);
}
mysqli_close($con);


?>