<?php
	session_start();
	include "connect.php";	
	if(isset($_SESSION['admin_login'])){ header("location:home.php");}
	
	if(isset($_POST['Login']) && $_POST['Login']=='Master')
	{
		$username=$_POST['username'];
		$password=md5($_POST['password']);
		$checkLogin=mysqli_query($conn,"SELECT * FROM admin_details WHERE admin_id ='".$username."' AND admin_password='".$password."'");
		if(mysqli_num_rows($checkLogin)>0){
			$result = mysqli_fetch_array($checkLogin);			
				$_SESSION['admin']=$username;
				$_SESSION['admin_login']=true;			
				header("location:home.php");			
		}else{
			 header("location:index.php?err");			 
		}
	}
$wr='<div class="alert alert-warning alert-dismissible" role="alert" style="margin-top: -18px; padding: 10px;"><button type="button" class="close" data-dismiss="alert"><span aria-hidden="true" style="margin-left:-50px; color:white;">&times;</span><span class="sr-only">Close</span></button><strong>Warning!</strong> Profile is not active.</div>';
//$success='<div class="alert alert-success alert-dismissible" role="alert" style="margin-top: -18px; padding: 10px;"><button type="button" class="close" data-dismiss="alert"><span aria-hidden="true" style="margin-left:-50px; color:white;">&times;</span><span class="sr-only">Close</span></button><strong>Success!</strong> Login is successfull.</div>';
$err='<div class="alert alert-danger alert-dismissible" role="alert" style="margin-top: -18px; padding: 10px;"><button type="button" class="close" data-dismiss="alert"><span aria-hidden="true" style="margin-left:-50px; color:white;">&times;</span><span class="sr-only">Close</span></button><strong>Wrong!</strong> Invalid credentials.</div>';
?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>:: SCSCROWD  | Log in ::</title>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">  
  <link rel="stylesheet" href="assets/bower_components/bootstrap/dist/css/bootstrap.min.css">
  <link rel="stylesheet" href="assets/bower_components/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="assets/bower_components/Ionicons/css/ionicons.min.css">  
  <link rel="stylesheet" href="assets/dist/css/AdminLTE.min.css">
  <link rel="stylesheet" href="assets/plugins/iCheck/square/blue.css">
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">  
</head>
<body class="hold-transition login-page" style="height:auto; background: linear-gradient(135deg,#c5f4e0 0,#c5f4e0 100%);">
<div class="login-box">
  <div class="login-logo">
    <h2 style="color:#ff0000" >SCSCROWD ADMIN</h2>
  </div> 
  <div class="login-box-body" style="box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
}">
    <p class="login-box-msg">Login to start your session</p>
	 <div id="response"><?php if(isset($_GET['wr'])){ echo $wr; } ?><?php if(isset($_GET['err'])){ echo $err; } ?></div>
     <form id="frm_login" role="form" action="" method="POST">
		<input type="hidden" name="Login" id="Login" value="Master" />
	 <div class="input-group">
		<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
		<input type="text" name="username" class="form-control" placeholder="Username" required autocomplete="off">
	</div>    <br/>
	<div class="input-group">
		<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
		<input type="password" name="password" class="form-control" placeholder="Password" required autocomplete="off">
	</div>  <br/>      
      <div class="row">         
        <div class="col-xs-4">
          <button id="ret" type="submit" class="btn btn-success btn-block btn-flat pull-left">Login Now</button>
        </div>    
      </div><div class="input-group"><br>
	   <!--<a href="signup.php">Do n't have a account? Click here for registration</a>-->
	   </div>
    </form>     
  </div>  
</div>
<script src="assets/bower_components/jquery/dist/jquery.min.js"></script>
<script src="assets/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="assets/plugins/iCheck/icheck.min.js"></script>
<script>
  $(function () {
    $('input').iCheck({
      checkboxClass: 'icheckbox_square-blue',
      radioClass: 'iradio_square-blue',
      increaseArea: '20%' /* optional */
    });
  });
</script>
</body>
</html>