<?php include("header.php"); 
 include("side.php"); 
  include("../db.php"); 
extract($_GET);
if(isset($submit)){

$rr=mysqli_query($conn,"SELECT * FROM `location` WHERE city='$name'");

if(mysqli_num_rows($rr) >0 ){
	 $alert=' <div class="alert alert-danger">City Name <b>Already Added please enter another!!</b></div>';
} else {
 $sql=mysqli_query($conn,"INSERT INTO `location`( `city`, `status`) VALUES ('$name', '$status')");
 $alert=' <div class="alert alert-success">Location <b>successfully Added!!</b></div>';
} }
 ?>
 <style >
 	.im{
	  height: 80px!important;
    width: 80px!important;
    margin-top: -20px;
 	}
 	.card-editor {
    border: 1px solid #ced4da !important;
}

 </style>
            <div id="layoutSidenav_content">
                <main>
                    <div class="container-fluid">
                        <h2 class="mt-30 page-title">Locations</h2>
                        <ol class="breadcrumb mb-30">
                            <li class="breadcrumb-item"><a href="index.php">Dashboard</a></li>
                            <li class="breadcrumb-item"><a href="locations.php?main=3&cat=1">Locations</a></li>
                            <li class="breadcrumb-item active">Add Location</li>
                        </ol>
                        <div class="row">
							<div class="col-lg-5 col-md-6">
								<div class="card card-static-2 mb-30">
									<div class="card-title-2">
										<h4>Add New Location</h4>
									</div>
					 				<div class="card-body-table">
										<div class="news-content-right pd-20">
											<?php if(isset($alert)) { echo $alert; } ?>
											<form action="" method="get">
											<div class="form-group">
												<label class="form-label">City Name*</label>
												<input type="text" class="form-control" name="name" placeholder="City Name" required/>
											</div>
											<div class="form-group">
												<label class="form-label">Status*</label>
												<select id="status" name="status" class="form-control" required/>
													<option selected="" value="1">Active</option>
													<option value="0">Inactive</option>
												</select>
											</div>
											<button class="save-btn hover-btn" name="submit" type="submit">Add New</button>
											</form>
										</div>
									</div>
								</div>
							</div>
                        </div>
                    </div>
                </main>
              <?php include("footer.php"); ?>
