<?php include ("../../include/dbconnect.php");
if ($submit == "Submit")
{
	if(!empty($name))
	{
		$result = mysqli_query($conn,"select location from area where location = '$name' ") or die(mysqli_error());
		$row =mysqli_fetch_row($result);
		
		if(empty($row))
		{
			
			$aresult = mysqli_query($conn,"select max(areacode) from area  ") or die(mysqli_error());
			$arow =mysqli_fetch_row($aresult);
			if(empty($arow))
			{
				$acode = '1001';
			}
			else
			{
				$acode = $arow[0]+1;
			}
					
			$query="insert into area values ('$name','$state','$country','$acode',NULL)";
			mysqli_query($conn,$query) or 	die(mysqli_error());
		}
	}
}
?>
<meta http-equiv="refresh" content="0 url=index.html">

