<?php 
session_start();
include('dbcon.php'); 


// If form submitted, insert values into the database
if(isset($_POST['submit']))
{
$username=$_POST['user'];
$password=$_POST['pass'];

//for security
$username=mysqli_real_escape_string($con,htmlentities(trim($username)));           //Escape special characters in a string 
$password=mysqli_real_escape_string($con,htmlentities(trim($password)));
$error="";

//Checking is user existing in the database or not
	$query="SELECT * FROM tbl_admin WHERE username='$username' && password='$password'";
	$result=mysqli_query($con,$query);
	$row=mysqli_num_rows($result);
	if($row==1)
	{
		$_SESSION['login']=$username;
		$_SESSION['status']="Login Successfully";
        $_SESSION['status_code']="success";
		echo "<script>window.location.href='dashboard.php';</script>";   //redirect user to home.php
    }
	else
	{  
	$_SESSION['status']="Username or  Password is not match! Please Try Again....";
        $_SESSION['status_code']="error";
		//header('location:index');
	}
}
?>






<!DOCTYPE html>
<html lang="en">


<head>
  <meta charset="utf-8"/>
  <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
  <meta name="description" content=""/>
  <meta name="author" content=""/>
  <title>Admin Login</title>
  <!--favicon-->
  <link rel="icon" href="assets/images/favicon.ico" type="image/x-icon">
  <!-- Bootstrap core CSS-->
  <link href="assets/css/bootstrap.min.css" rel="stylesheet"/>
  <!-- animate CSS-->
  <link href="assets/css/animate.css" rel="stylesheet" type="text/css"/>
  <!-- Icons CSS-->
  <link href="assets/css/icons.css" rel="stylesheet" type="text/css"/>
  <!-- Custom Style-->
  <link href="assets/css/app-style.css" rel="stylesheet"/>
  
  
   <style>
   
   body{
   background-image:url(images/bgg.jpg);  
       
       
   }  
      
  </style>
  
  
 
</head>

<body class="bg-dark" style="background-color:gray;">
 <!-- Start wrapper-->
 <div id="wrapper">
	<div class="card card-authentication1 mx-auto my-5">
		<div class="card-body">
		 <div class="card-content p-2">
		 <div class="text-center">
		 	<a href="index.php" style="font-weight: 600;color:#4285f4;font-size:40px"> MGS</a>
		 		<!--<img src="images/deltalogo.png" alt="logo icon" style="width:75%;">-->
		 	</div>
		  <div class="card-title text-uppercase text-center py-3">Sign In</div>
		    <form method="POST">
			  <div class="form-group">
			  <label for="exampleInputUsername" class="">Username</label>
			   <div class="position-relative has-icon-right">
				  <input type="text" id="exampleInputUsername" name="user" class="form-control input-shadow" placeholder="Enter Username" required>
				  <div class="form-control-position">
					  <i class="icon-user"></i>
				  </div>
			   </div>
			  </div>
			  <div class="form-group">
			  <label for="exampleInputPassword" class="">Password</label>
			   <div class="position-relative has-icon-right">
				  <input type="password" id="exampleInputPassword" name="pass" class="form-control input-shadow" placeholder="Enter Password" required>
				  <div class="form-control-position">
					  <i class="icon-lock"></i>
				  </div>
			   </div>
			  </div>
			<div class="form-row">
			 <!--<div class="form-group col-6">
			   <div class="icheck-material-primary">
                <input type="checkbox" id="user-checkbox" checked="" />
                <label for="user-checkbox">Remember me</label>
			  </div>
			 </div>-->
			 <!--div class="form-group col-6 text-right">
			  <a href="authentication-reset-password.html">Reset Password</a>
			 </div>-->
			</div>
			 <button type="submit" name="submit" class="btn btn-primary shadow-success btn-block waves-effect waves-light">Sign In</button>
			  <!--div class="text-center mt-3">Sign In With</div>
			  
			 <div class="form-row mt-4">
			  <div class="form-group mb-0 col-6">
			   <button type="button" class="btn btn-facebook shadow-facebook btn-block text-white"><i class="fa fa-facebook-square"></i> Facebook</button>
			 </div>
			 <div class="form-group mb-0 col-6 text-right">
			  <button type="button" class="btn btn-twitter shadow-twitter btn-block text-white"><i class="fa fa-twitter-square"></i> Twitter</button>
			 </div>
			</div-->
			 
			 </form>
		   </div>
		  </div>
		  <!--div class="card-footer text-center py-3">
		    <p class="text-muted mb-0">Do not have an account? <a href="authentication-signup.html"> Sign Up here</a></p>
		  </div>-->
	     </div>
    
     <!--Start Back To Top Button-->
    <a href="javaScript:void();" class="back-to-top"><i class="fa fa-angle-double-up"></i> </a>
    <!--End Back To Top Button-->
	</div><!--wrapper-->
	
  <!-- Bootstrap core JavaScript-->
  <script src="assets/js/jquery.min.js"></script>
  <script src="assets/js/popper.min.js"></script>
  <script src="assets/js/bootstrap.min.js"></script>
  
  <!-- Sweet alert js -->
   <script src="js/sweetalert.js"></script>
   <?php 
   if(isset($_SESSION['status']) && $_SESSION['status']!=''	)
   {
	  
   ?>
  <script>
 swal({
  title: "<?php echo $_SESSION['status'];?>",
  //text: "You clicked the button!",
  icon: "<?php echo $_SESSION['status_code'];?>",
  button: "Ok!",
});
  </script>
  <?php 
   unset($_SESSION['status']);
   }
   ?>
</body>


</html>
