<?php
   ob_start();
   session_start();
   if (isset($_SESSION['username']) && isset($_SESSION['valid'])) {            
        header('location: index.php');
    }
?>
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="Israel H">
    <meta name="generator" content="Jekyll v3.8.5">
    <title>Iniciar sesión</title>
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
    <style>
    html,
body {
  height: 100%;
}

body {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: center;
  align-items: center;
  padding-top: 40px;
  padding-bottom: 40px;
  background-color: #f5f5f5;
}

.form-signin {
  width: 100%;
  max-width: 330px;
  padding: 15px;
  margin: 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;
}
.bd-placeholder-img {
        font-size: 1.125rem;
        text-anchor: middle;
      }

      @media (min-width: 768px) {
        .bd-placeholder-img-lg {
          font-size: 3.5rem;
        }
      }
</style>
  </head>
  <body class="text-center">
    <form class="form-signin" method="POST" action="login.php">
    <img class="mb-4" src="http://2rvisual.com/images/logo_2r-11-crop-u15077.png" alt="2R Visual" height="72">
  <h1 class="h3 mb-3 font-weight-bold">Iniciar sesión</h1>
  <?php            
            if (isset($_POST['login']) && !empty($_POST['username']) 
               && !empty($_POST['password'])) {
				
               if ($_POST['username'] == 'Integrante' && 
                  $_POST['password'] == 'IsraelH_visual_Xal') {
                  $_SESSION['valid'] = true;
                  $_SESSION['timeout'] = time();
                  $_SESSION['username'] = 'Integrante';
                  
                  header('location: index.php');
                }else {
                  echo '<div class="alert alert-danger" role="alert">El nombre de usuario y/o contraseña son incorrectos.</div>';
               }
            }
         ?>
  <label for="inputEmail" class="sr-only">Usuario</label>
  <input type="text" id="inputEmail" name="username" class="form-control" placeholder="Escribe tu nombre de usuario" required autofocus>
  <label for="inputPassword" class="sr-only">Contraseña</label>
  <input type="password" id="inputPassword" name="password" class="form-control" placeholder="Escribe tu contraseña" required>
  <button class="btn btn-lg btn-dark btn-block" name="login" type="submit">Entrar</button>
  <p class="mt-5 mb-3 text-muted">&copy; <?=date('Y')?></p>
</form>
</body>
</html>
