<!DOCTYPE html>
<html>
<head>
	<?php include('include/head.php'); ?>
	
	<!-- <title>Add Gallery </title> -->
</head>
<body>
	<?php include('include/header.php'); ?>
	<?php include('include/sidebar.php'); ?>
	<div class="main-container">
		<div class="pd-ltr-20 customscroll customscroll-10-p height-100-p xs-pd-20-10">
			<div class="min-height-200px">
				<div class="page-header">
					<div class="row">
						<div class="col-md-6 col-sm-12">
							<div class="title">
								<h4>Add Taluka</h4>
							</div>
							<nav aria-label="breadcrumb" role="navigation">
								<ol class="breadcrumb">
									<li class="breadcrumb-item"><a href="dashboard.php">Dashboard</a></li>
									<!-- <li class="breadcrumb-item"><a href="#">Gallery</a></li> -->
									<li class="breadcrumb-item"><a href="view_taluka.php">Taluka</a></li>
                  <li class="breadcrumb-item active" aria-current="page">Add Taluka</li>
								</ol>
							</nav>
						</div>
            <div class="col-md-6 col-sm-12 text-right">
              <div class="dropdown">
                <a class="btn btn-primary" href="view_taluka.php" role="button">
                  View Taluka
                </a>
              </div>
            </div>
			
					</div>
				</div>


				
<div class="pd-20 bg-white border-radius-4 box-shadow mb-30">
					<div class="clearfix">
						<div class="pull-left">
							<!-- <h4 class="text-blue">Add Photo</h4> -->
						</div>
						
					</div><br> 
					
					<form method="post" enctype="multipart/form-data">
								<?php


//error_reporting(0);

    if(isset($_POST['submit']))
    {
        extract($_POST);
        $ds="select * from tbl_taluka where fld_taluka_id!='".$_POST['taluka']."' and fld_taluka_name='".$_POST['taluka']."' and fld_city_id='".$_POST['city']."' and fld_state_id='".$_POST['state']."' and fld_taluka_delete='0'";
        $anbc=mysqli_query($connect,$ds) or die(mysqli_error($connect));

        if(mysqli_num_rows($anbc)==1)
        {
          echo '<script type="text/javascript">'; 
          echo 'alert("Taluka Is Already Exist");';
          echo "window.location.href = 'view_taluka.php';";
          echo '</script>'; 
          return true;

        }    
        else
        {
           $query="INSERT into tbl_taluka(fld_state_id,fld_city_id,fld_taluka_name) VALUES('$state','$city','$taluka'); ";
               
                 $add2=mysqli_query($connect,$query); 

                
        if($add2)
       {
         echo '<script type="text/javascript">';
         echo " alert('Taluka Added Successfully.');";
         echo 'window.location.href = "view_taluka.php";';
         echo '</script>';
  
        }
       else
      {
       echo '<script type="text/javascript">';
       echo " alert('Taluka Not Added.');";
       echo '<script>';
      }
    }
  }

?> 				
						<div class="form-group row">
							<label class="col-sm-12 col-md-2 col-form-label">State Name <span class="text-danger">*</span> : </label>
							<div class="col-sm-12 col-md-10">
								<select name="state" class="form-control" id="state" required="">
                    <option value="">Select State</option>
                                    <?php
                                        
                                        $query1=mysqli_query($connect,"select distinct fld_state_name,fld_state_id from tbl_state where fld_state_delete='0' order by fld_state_id desc");
                                        while($row=mysqli_fetch_assoc($query1)){
                                          extract($row);

                                      ?>
                                    <option value="<?php echo $row['fld_state_id'];?>"><?php echo $row['fld_state_name'];?></option>
                                    <?php  }?>
                </select>
							</div>
						</div>
						<div class="form-group row">
              <label class="col-sm-12 col-md-2 col-form-label">City Name <span class="text-danger">*</span> : </label>
              <div class="col-sm-12 col-md-10">
                <select name="city" class="form-control" id="city" required="">
                   <option value="">Select City</option>
                                    
                </select>
              </div>
            </div>
            <div class="form-group row">
              <label class="col-sm-12 col-md-2 col-form-label">Taluka Name <span class="text-danger">*</span> : </label>
              <div class="col-sm-12 col-md-10">
                <input type="text" name="taluka" class="form-control" required="" placeholder="Enter Taluka Name" oninput="this.value = this.value.replace(/[^a-zA-Z\s.]/g, '').replace(/(\..*)\./g, '$1');">
              </div>
            </div>
												
						<div class="form-group row">
							<div class="col-sm-12 col-md-10">
							<center><input class="btn btn-success" value="Submit" type="submit" name="submit">&nbsp;
								<input class="btn btn-danger" value="Reset" type="reset">&nbsp;
								<a href="view_taluka.php" class="btn btn-warning">Back</a></center>
							</div>
						</div>
					</form>
	</div>
			<?php include('include/footer.php'); ?>
		</div>
	</div>
	<?php include('include/script.php'); ?>
<script type="text/javascript">
  $(document).ready(function(){
    $("select#state").change(function(){
          var u = $("#state option:selected").val();
      
          $.ajax({
              type: "POST",
              url: "city.php", 
              data: { state : u  } 
          }).done(function(data){
              $("#city").html(data);
          });
      });
  });
</script>
</body>
</html>
