<?php session_start(); ?>
<?php require_once("sass/connection.php"); ?>


<?php
if(isset($_POST['submit']))
    {

        $user_name = mysqli_real_escape_string($connection,$_POST['user_name']);
        $password = mysqli_real_escape_string($connection,md5($_POST['password']));
 
 $check=mysqli_query($connection,"select * from users where user_name='$user_name' AND password='$password'");
$checkrows=mysqli_num_rows($check);
if($checkrows>0){
$found_user = mysqli_fetch_array($check);
$_SESSION['user_id'] = $found_user['users_id'];



echo "<script>window.location='index.php'</script>";	}

else{ 
$message= "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' 
          aria-hidden='true'>
          &times;
        </button>Sorry, Your ID and Pasword Did Not Match !</div>";
}

}
?>


<!DOCTYPE html>
<html class="bg-black">
    <head>
        <meta charset="UTF-8">
        <title>SMART SALE | Log in</title>
        <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
        <!-- bootstrap 3.0.2 -->
        <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
        <!-- font Awesome -->
        <link href="css/font-awesome.min.css" rel="stylesheet" type="text/css" />
        <!-- Theme style -->
        <link href="css/AdminLTE.css" rel="stylesheet" type="text/css" />

        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
          <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
        <![endif]-->
    </head>
    <body class="bg-black">

        <div class="form-box" id="login-box">
            <div class="header">Sign In</div>
            <form method="post" action="<?php echo "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>">
                <div class="body bg-gray">
                <?php
						if (!empty($message))
						echo "<font color='#FF0000'><h4>$message</h4></font>";
                    ?>
                    <div class="form-group">
                        <input type="text" name="user_name" class="form-control" placeholder="User Name"/>
                    </div>
                    <div class="form-group">
                        <input type="password" name="password" class="form-control" placeholder="Password"/>
                    </div>          
                    <div class="form-group">
                        <input type="checkbox" name="remember_me"/> Remember me
                    </div>
                </div>
                <div class="footer">                                                               
                    <button type="submit" name="submit" class="btn bg-olive btn-block">Sign me in</button>  
                    
                    <p><a href="#">I forgot my password</a></p>
                    
                    <!--<a href="register.html" class="text-center">Register a new membership</a>-->
                </div>
            </form>

      
        </div>


        <!-- jQuery 2.0.2 -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
        <!-- Bootstrap -->
        <script src="js/bootstrap.min.js" type="text/javascript"></script>        

    </body>
</html>