<?php
session_start();
$error = '';

// jika sudah login, alihkan ke halaman dasbor
if (isset($_SESSION['user'])) {
  header('Location: ../dasbor/index.php');
  exit();
}

// Ambil pesan error dari session (jika ada)
if (isset($_SESSION['login_error'])) {
  $error = $_SESSION['login_error'];
  unset($_SESSION['login_error']);
}
?>
?>

<?php include('../_partials/top-login.php') ?>

<div class="row" style="margin-top: 75px">
  <div class="col-md-4 col-md-offset-4">
    <div class="well">
      <form class="form-signin" method="post" action="../login/proses-login.php">
      <div class="text-center">
        <img src="../../assets/img/NH.png" alt="Logo Admin" class="admin-logo">
      </div>
        <h2 class="form-signin-heading text-center ">
          <strong>Silahkan Login</strong>        
          <?php if ($error != ''): ?>
            <p style="color:red; font-size: 15px;"><?php echo $error; ?></p>
          <?php endif; ?>       
        </h2>        
        <input type="text" name="username_user" class="form-control" placeholder="Username" autofocus required>

        <input type="password" name="password_user" class="form-control" placeholder="Password" required>

        <button class="btn btn-lg btn-primary btn-block" type="submit">
          <i class="glyphicon glyphicon-log-in"></i> Log in
        </button>
      </form>
    </div>
  </div>
</div>

<?php include('../_partials/bottom-login.php') ?>
