<?php
include('db_connect.php');
error_reporting(1);
if(isset($_POST['admin_name'])){
	
	$admin_id = $_POST['admin_id'];
	$admin_name = $_POST['admin_name'];
    $shop_name = $_POST['shop_name'];
	$phone_no = $_POST['phone_no'];
	$admin_adress = $_POST['admin_adress'];
	$admin_city = $_POST['admin_city'];
	$delivery_area = $_POST['delivery_area'];
	$delivery_plan = $_POST['delivery_plan'];
	$morning_delivery_time = $_POST['morning_delivery_time'];
	$evening_delivery_time = $_POST['evening_delivery_time'];
	$cow_price = $_POST['cow_price'];
	$goat_price = $_POST['goat_price'];
	$buffalo_price = $_POST['buffalo_price'];
	$token = $_POST['token'];


	
				$query="INSERT INTO `admin_details`(`admin_id`,`admin_name`, `shop_name`, `phone_no`, `admin_adress`, `admin_city`, `delivery_area`, `delivery_plan`, `morning_delivery_time`, `evening_delivery_time`, `token`)
				VALUES ('$admin_id','$admin_name','$shop_name','$phone_no', '$admin_adress', '$admin_city', '$delivery_area', '$delivery_plan', '$morning_delivery_time', '$evening_delivery_time', '$token')";
			
	if(mysqli_query($con,$query))
				{
				     $query = "UPDATE milk_categories SET admin_id='$admin_id', price_per_litre='$cow_price' WHERE category_name='Cow'";
				     
				       if (mysqli_query($con, $query)) {
                          $query = "UPDATE milk_categories SET admin_id='$admin_id', price_per_litre='$goat_price' WHERE category_name='Goat'";
				     
				       if (mysqli_query($con, $query)) {
				           
				            $query = "UPDATE milk_categories SET admin_id='$admin_id', price_per_litre='$buffalo_price' WHERE category_name='Buffalo'";
				     
				       if (mysqli_query($con, $query)) {
				echo "Successfully Saved";
         
     } else {
         
         echo "query failed 3";
     }

     } else {
         
         echo "query failed 2";
     }
				    
     } else {
         
         echo "query failed 1";
     }
				    
				   

	}
	else{
	    echo 'Request Query Failed!' . mysqli_error($con);
	}
	

}
else{
    	    echo 'Request Failed! Username Null';

}

mysqli_close($con);
?>
    
    
    
    
    
    
    
    
    
		
		
	
	