<?php
include_once 'set.php';
$_title = "DPVZ - Thanh Toán".$_name_site;
include_once 'head.php';
$alert = null;
if($_login == null)
{
	if(isset($_POST['username']))
	{

			$user = htmlspecialchars($_POST['username']);
			$pass = htmlspecialchars($_POST['password']);
			$select = _fetch(_select("*",'player',"username='$user'"));
			if($select['password'] == $pass)
			{
				$_SESSION['user'] = $user;
				header('location:/user');
			}
			else
			{
                echo '
                <script type="text/javascript">
                
                $(document).ready(function(){
                
                  swal({
                        title: "Thất bại",
                        text: "Thông tin đăng nhập không chính xác!",
                        type: "error",
                        confirmButtonText: "OK",
                  })
                });
                
                </script>
                ';
			}
		
	}
}
else
{
	header("location:/");
}

?>
<main class="flex-grow-1 flex-shrink-1">

    <div class="container pb-5">
        <form class="form-signin" method="POST">
            <input type="hidden" name="_token" value="JEGpj39vMoqzUAPDoHWTY8Y4jJiy4t0mhPST9nds">
<br><h1 class="h3 mb-3 font-weight-normal text-center">Vui lòng đăng nhập</h1>
            <?php echo $alert; ?>
            <label class="sr-only">Tài khoản</label>
            <input type="text" class="form-control" placeholder="Tài khoản" required="" name="username">
            <label class="sr-only">Mật khẩu</label>
            <input type="password" class="form-control" placeholder="Mật khẩu" required="" name="password">
            <div class="checkbox mb-3">
                <label>
                    <input type="checkbox" name="remember" value="forever"> Nhớ đăng nhập
                </label>
            </div>
            <button class="btn btn-info btn-block" type="submit">Đăng nhập</button>
            <div class="text-center pt-2">
                Bạn chưa có tài khoản? <a href="/register">Đăng ký ngay</a>
            </div>
        </form>
        <style>
        .form-signin {
            width: 100%;
            max-width: 400px;
            padding: 15px;
            margin: 0 auto;
        }

        .form-signin .checkbox {
            font-weight: 400;
        }

        .form-signin .form-control {
            position: relative;
            box-sizing: border-box;
            height: auto;
            padding: 10px;
            font-size: 16px;
        }

        .form-signin .form-control:focus {
            z-index: 2;
        }

        .form-signin input[type="email"] {
            margin-bottom: -1px;
            border-bottom-right-radius: 0;
            border-bottom-left-radius: 0;
        }

        .form-signin input[type="password"] {
            margin-bottom: 10px;
            border-top-left-radius: 0;
            border-top-right-radius: 0;
        }
        </style>
		<?php
include_once 'end.php';
?>
</main>
