<?php

require_once("config/configDB.php"); 
$expense   = stripslashes($_POST['expense']);

$count=0;
$check_query	= mysqli_query($conn,"SELECT count(expense) as counts FROM expense_master WHERE expense = '$expense' "); // 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 = "expenseMaster.php";</script>
<?php
		

}		
else
{

$sql  = "INSERT INTO expense_master (expense, flag) VALUES ('$expense', '1')";

mysqli_query($conn,$sql);
}

header("Location:expenseMaster.php");


?>