<?php
date_default_timezone_set('Asia/Kolkata');
require_once("config/configDB.php"); 

$areatcode   = stripslashes($_POST['areatcode']);
$areaname   = stripslashes($_POST['areaname']);
$area_tamil   = $_POST['area_tamil'];

$create_date  	        = date("Y-m-d H:i:s"); 
//productcode, productname, purchase_rate, gst, hsn_code,description, create_date, flag FROM `product_master`
$autoinc=mysqli_query($conn,"ALTER TABLE area_master CHANGE id id INT(11) NOT NULL AUTO_INCREMENT ");


$count=0;
$check_query	= mysqli_query($conn,"SELECT count(areaname) as counts FROM area_master WHERE areaname = '$areaname' "); // Check the database


while($row = mysqli_fetch_array($check_query)){
$count=$row['counts'];
}
if($count!=0){
// Already Exsist


		echo "<script> alert ('Data Inserted Success.');</script>";
		?>
<script language="javascript">window.location.href = "areaMasterDashboard.php";</script>
<?php
		

}		
else
{

$sql  = "INSERT INTO area_master (areacode, areaname,area_tamil, create_date, isdelete) VALUES ('$areatcode','$areaname','$area_tamil','$create_date', '1')";



mysqli_query($conn,$sql);

$last_id = mysqli_insert_id($conn);


}
$conn->close();

// productID, customerID, productcode, productname, prodct_description, hsn_code, gst, purchase_rate, sale_rate



header("Location:areaMasterDashboard.php");


?>