<?php
    session_start();
    include '../config.php';
    $date = date("Y-m-d H:i");
    $public_ip = $_SERVER['REMOTE_ADDR'];
    $submit = $_POST['submit'];
    if(isset($submit))
    {
        $uname      = $_POST['username'];
        $password   = $_POST['password'];
        
        if($uname != "" || $password != ""  || $regime_type != "" )
        {
            if($uname != "admin" || $password != "admin"  )
            {
                $error = "Wrong Credentials.. Try again.."; 
            }
            else
            {
                // $sql = "INSERT INTO activity_log (user_id, module, login_date_time,public_ip) VALUES ('$uname', 0,'$date','$public_ip')";
                // if ($con->query($sql) === TRUE)
                // {
                    $_SESSION['uname'] = "admin";
                    $_SESSION['session_id'] = $con->insert_id;
                    header("Location: create.php");
                // } 
                // else
                // {
                //     $error =  "Error: " . $sql . "<br>" . $con->error;
                // }                    
            }
        }
        else
        {
            $error = "Please Select All Fields!!!";   
        }    	
    }
    else
    {
        $error = "Please Login to proceed!!!";   
    }
?>
<!DOCTYPE html>
<html>
    <head>
        <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <title>Login</title>
        <style>
            body 
            {
                margin: 0;
                padding: 0;
                background-color: #9c9c9ca3;
                /* background-image: url("img/img10.jpg"); */
                background-size: cover;
                height: 100vh;
            }
            #login .container #login-row #login-column #login-box
            {
                margin-top: 42px;
                max-width: 600px;
                height: 350px;
                /* border: 1px solid #9C9C9C; */
                background-color: #514d4dbd;
                /* //#eaeaeae3; */
            }
            #login .container #login-row #login-column #login-box #login-form {
                padding: 20px;
            }
            #login .container #login-row #login-column #login-box #login-form #register-link {
                margin-top: -85px;
            }
            footer 
            {
                position: fixed;
                left: 0;
                bottom: 0;
                width: 100%;
                background-color: #255a89ba;
                /* #6c757d   ; */
                color: white;
                text-align: center;
            }
        </style>
    </head>

    <body>
        <div id="login">
            <h3 class="text-center text-white pt-5">Secure Login</h3>
            <div class="container">
                <div id="login-row" class="row justify-content-center align-items-center">
                    <div id="login-column" class="col-md-6">
                        <div id="login-box" class="col-md-12">
                            <form id="login-form" class="form" action="" method="post">
                                <h3 class="text-center text-info">Login</h3>
                                <span style="color: red; font-size: x-large;margin-left: 111px;"><?php echo $error; ?></span>
                                <div class="form-group">
                                    <label for="username" class="text-info">Username:</label><br>
                                    <input type="text" name="username" id="username" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label for="password" class="text-info">Password:</label><br>
                                    <input type="password" name="password" id="password" class="form-control">
                                </div>
                                <div class="form-group">
                                    <input type="submit" name="submit" class="btn btn-info btn-md" value="submit">
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
    <footer class="page-footer font-small blue">
        <div class="footer-copyright text-center py-3">© <?php echo date('Y'); ?> Copyright: m2clearance.com . Powered By
            <a href="http://m2clearance.com/" style="color: darkblue;"> m2clearance.com</a>
        </div>
    </footer>
    <script>
    // document.onkeydown = function(e)
    // {
    //     if(event.keyCode == 123)
    //     {
    //         return false;
    //     }
    //     if(e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)) 
    //     {
    //         return false;
    //     }
    //     if(e.ctrlKey && e.shiftKey && e.keyCode == 'C'.charCodeAt(0)) 
    //     {
    //         return false;
    //     }
    //     if(e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)) 
    //     {
    //         return false;
    //     }
    //     if(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0))
    //     {
    //         return false;
    //     }
    // }
    </script>
</html>
