<?php 
ob_start(); 
error_reporting(0);
include("connect.php");
include("link_head.php");
session_start(); 
?>
<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="utf-8" />
        <title>Tarkashcorp | Admin Dashboard</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta content="width=device-width, initial-scale=1" name="viewport" />
        <meta content="Preview page of Metronic Admin Theme #6 for " name="description" />
        <meta content="" name="author" />
        <!-- BEGIN GLOBAL MANDATORY STYLES -->
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&subset=all" rel="stylesheet" type="text/css" />
        <link href="assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
        <link href="assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css" />
        <link href="assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
        <link href="assets/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css" rel="stylesheet" type="text/css" />
        <!-- END GLOBAL MANDATORY STYLES -->
        <!-- BEGIN PAGE LEVEL PLUGINS -->
        <link href="assets/global/plugins/select2/css/select2.min.css" rel="stylesheet" type="text/css" />
        <link href="assets/global/plugins/select2/css/select2-bootstrap.min.css" rel="stylesheet" type="text/css" />
        <!-- END PAGE LEVEL PLUGINS -->
        <!-- BEGIN THEME GLOBAL STYLES -->
        <link href="assets/global/css/components.min.css" rel="stylesheet" id="style_components" type="text/css" />
        <link href="assets/global/css/plugins.min.css" rel="stylesheet" type="text/css" />
        <!-- END THEME GLOBAL STYLES -->
        <!-- BEGIN PAGE LEVEL STYLES -->
        <link href="assets/pages/css/login.min.css" rel="stylesheet" type="text/css" />
        <!-- END PAGE LEVEL STYLES -->
        <!-- BEGIN THEME LAYOUT STYLES -->
        <!-- END THEME LAYOUT STYLES -->
        <link rel="shortcut icon" href="favicon.ico" />
		
		<style>
		::-webkit-scrollbar {
			display: none;
			overflow: hidden;
		}
		</style>
		<script>
		window.onscroll = function () {
		window.scrollTo(0,0);
		}
		</script>
		
		
		
		</head>
    <!-- END HEAD -->

    <body class=" login">
        <!-- BEGIN LOGO -->
        <div class="logo">
            <a href="index.php">
                <img src="assets/pages/img/app_logo2.png" height="70px" width="200px" alt="" /> </a>
        </div>
        <!-- END LOGO -->
        <!-- BEGIN LOGIN -->
        <div class="content" style="margin-top:5px;">
            <!-- BEGIN LOGIN FORM -->
            <form class="login-form" method="post">
                <h3 class="form-title font-green">Sign In</h3>
                <div class="alert alert-danger display-hide">
                    <button class="close" data-close="alert"></button>
                    <span> Enter user name and password. </span>
                </div>
                <div class="form-group">
                    <!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
                    <label class="control-label visible-ie8 visible-ie9">User name</label>
                    <input class="form-control form-control-solid placeholder-no-fix" type="text" autocomplete="off" placeholder="Username" name="distributor_email" /> </div>
                <div class="form-group">
                    <label class="control-label visible-ie8 visible-ie9">Password</label>
                    <input class="form-control form-control-solid placeholder-no-fix" type="password" autocomplete="off" placeholder="Password" name="password" /> </div>
                <div class="form-actions">
				<input id="submit" type="submit" name="sub" class="btn green uppercase"  value="Log In"/>
        <!--        <label class="rememberme check mt-checkbox mt-checkbox-outline">
                        <input type="checkbox" name="remember" value="1" />Remember
                        <span></span>
                    </label>
                    <a href="javascript:;" id="forget-password" class="forget-password">Forgot Password?</a> -->
                </div>
        <!--    <div class="login-options">
                    <h4>Or login with</h4>
                    <ul class="social-icons">
                        <li>
                            <a class="social-icon-color facebook" data-original-title="facebook" href="javascript:;"></a>
                        </li>
                        <li>
                            <a class="social-icon-color twitter" data-original-title="Twitter" href="javascript:;"></a>
                        </li>
                        <li>
                            <a class="social-icon-color googleplus" data-original-title="Goole Plus" href="javascript:;"></a>
                        </li>
                        <li>
                            <a class="social-icon-color linkedin" data-original-title="Linkedin" href="javascript:;"></a>
                        </li>
                    </ul>
                </div> -->
				<!--
                <div class="create-account">
                    <p>
                        <a href="javascript:;" id="register-btn" class="uppercase">Create an account</a>
                    </p>
                </div>
				-->
            </form>
            <!-- END LOGIN FORM -->
            <!-- BEGIN FORGOT PASSWORD FORM -->
            
            <!-- END REGISTRATION FORM -->
        </div>
		
<?php
if(isset($_POST['sub']))
{   
	$email=$_POST['distributor_email'];
	$password=$_POST['password'];
    $ip=$_SERVER['REMOTE_ADDR'];	
	
	date_default_timezone_set('Asia/Calcutta');
	$time = date("h:i:sa");
	$date  = date("Y-m-d");
	$dateTime =$date.' '.$time;
	
	$sql=mysqli_query($con,"Select * from tbl_distributor_users where distributor_email='$email' AND password='$password' AND status='Active'");
	$fetch_data=mysqli_fetch_array($sql);
	if(mysqli_num_rows($sql)=='1')
	{
	  $id=$fetch_data['distributor_user_id'];
	  $login_datetime=$fetch_data['login_datetime'];
	  $_SESSION['distributor_user_id']=$fetch_data['distributor_user_id'];
	  $_SESSION['distributor_name']=$fetch_data['distributor_name'];
	  $_SESSION['distributor_email']=$fetch_data['distributor_email'];
	  $_SESSION['user_role']=$fetch_data['user_role'];
	 
	  //if($login_datetime=="")
	 // {
	  $res = mysqli_query($con,"UPDATE tbl_distributor_users SET login_datetime='$dateTime' WHERE distributor_user_id='$id'");
	  if($res)
	  {	  
	    header('location:dashboard.php');
	  }
	  //}
	  //else
	  //{
	    ?>
			<!--	<script> alert("You are already logged in same browser.Please logout and then try again!"); </script> -->
		<?php
	  //}
	}
	else
	{
	  ?> 
		<ul id="noty_topCenter_layout_container" class="i-am-new" style="top: 20px; left: 510px; position: fixed; width: 310px; height: auto; margin: 0px; padding: 0px; list-style-type: none; z-index: 10000000;">
		 <li style="overflow: hidden; border-radius: 3px; border: 1px solid rgb(51, 51, 51); box-shadow: rgba(0, 0, 0, 0.2) 0px 1px 2px; color: rgb(255, 255, 255); opacity: 1; width: 310px; cursor: pointer; background: rgba(182, 70, 69, 0.9);">
		 <div class="noty_bar noty_type_alert" id="noty_268557658129368860">
		  <div class="noty_message" style="font-size: 11px; line-height: 14px; text-align: center; padding: 8px 10px 9px; width: auto; position: relative;">
		   <span class="noty_text">Incorrect Email And Password!</span>
		  </div>
		 </div>
		 </li>
		</ul>		
	  <?php
	}
}
?>       
         
        <div class="copyright"> 2018 &copy; <a target="_blank" href="http://www.belltechnology.in">Bell Technology</a></div>

        <!-- BEGIN CORE PLUGINS -->
        <script src="assets/global/plugins/jquery.min.js" type="text/javascript"></script>
        <script src="assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
        <script src="assets/global/plugins/js.cookie.min.js" type="text/javascript"></script>
        <script src="assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
        <script src="assets/global/plugins/jquery.blockui.min.js" type="text/javascript"></script>
        <script src="assets/global/plugins/bootstrap-switch/js/bootstrap-switch.min.js" type="text/javascript"></script>
        <!-- END CORE PLUGINS -->
        <!-- BEGIN PAGE LEVEL PLUGINS -->
        <script src="assets/global/plugins/jquery-validation/js/jquery.validate.min.js" type="text/javascript"></script>
        <script src="assets/global/plugins/jquery-validation/js/additional-methods.min.js" type="text/javascript"></script>
        <script src="assets/global/plugins/select2/js/select2.full.min.js" type="text/javascript"></script>
        <!-- END PAGE LEVEL PLUGINS -->
        <!-- BEGIN THEME GLOBAL SCRIPTS -->
        <script src="assets/global/scripts/app.min.js" type="text/javascript"></script>
        <!-- END THEME GLOBAL SCRIPTS -->
        <!-- BEGIN PAGE LEVEL SCRIPTS -->
        <script src="assets/pages/scripts/login.min.js" type="text/javascript"></script>
        <!-- END PAGE LEVEL SCRIPTS -->
        <!-- BEGIN THEME LAYOUT SCRIPTS -->
        <!-- END THEME LAYOUT SCRIPTS -->
        <script>
            $(document).ready(function()
            {
                $('#clickmewow').click(function()
                {
                    $('#radio1003').attr('checked', 'checked');
                });
            })
        </script>
    </body>

</html>