<?php

ob_start();
error_reporting(0);
session_start();
require_once('../../include/dbconnect.php');
if(isset($_GET['log']))
{
	session_destroy();
	header("Location: login.php");
}

$error="";

if( isset($_POST['log']) ) 
{
$uname=$_POST['u'];
$pass=$_POST['p'];									
$sql="SELECT * FROM admin WHERE username='$uname' and BINARY password='$pass'";
$res=mysqli_query($conn,$sql);
$row=mysqli_fetch_array($res);
$count = mysqli_num_rows($res); // if uname/pass correct it returns must be 1 row
		
if($count == 1) 
{
$id = $row['id'];
$must= $row['username'];
$name= $row['fullname'];

$_SESSION['id'] = $id;
$_SESSION['admin'] = $must;
$_SESSION['nm'] = $name;
			
			$dt = date("Y-m-d h:i:s");		
			$sql="update admin set LLogin='$dt' where id=$id";
			
			$result=mysqli_query($conn,$sql);
			
header("Location: ../index.php");
setcookie($must,"",time()-3600);

}else {
	$error = "Incorrect Credentials, Try again...";
}
		
}							
	//}				
?>	


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <meta name="keyword" content="">
<link href="../../iportal/images/favicon.png" rel="icon" />
    
    
    <link rel="shortcut icon" href="img/favicon.png">

    <title>LOGIN</title>

    <!-- Bootstrap CSS -->    
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <!-- bootstrap theme -->
    <link href="css/bootstrap-theme.css" rel="stylesheet">
    <!--external css-->
    <!-- font icon -->
    <link href="css/elegant-icons-style.css" rel="stylesheet" />
    <link href="css/font-awesome.css" rel="stylesheet" />
    <!-- Custom styles -->
    <link href="css/style.css" rel="stylesheet">
    <link href="css/style-responsive.css" rel="stylesheet" />

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 -->
    <!--[if lt IE 9]>
    <script src="js/html5shiv.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->
    <style>
            <style>
        body {
  font-family: Arial, sans-serif;
}

.icon_lock_alt, .icon_profile, .icon_key_alt {
  font-size: 24px;
  color: orange;
}

.input-group-addon {
  background-color: #23233f;
  border: none;
  border-radius: 5px 0 0 5px;
}

.input-group .form-control {
  border: none;
  border-radius: 0 5px 5px 0;
}

.btn-primary {
  color: #fff;
  background-color: orange;
  border: none;
  padding: 10px;
}

footer {
  position: fixed;
  bottom: 0;
  width: 100%;
  padding: 10px;
  background-color: #23233f;
  color: #fff;
  text-align: center;
}


    </style>
    </style>
</head>

<body class="" style="background: #000;"> 
  <header style="background-color: #23233f; color: #fff; padding: 20px; text-align: center;"> 
    <img src="https://newageunb.com/images/newage.png" alt=" Discoery Capital Bank" style="width: 200px; height: 50px; margin: 0 auto;"> 
  </header> 
  <div class="container" style="width: 400px; margin: 100px auto; background: #444; padding: 20px; border: 1px solid #555; border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);">
    <form class="login-form" method="post" action="login.php"> 
      <div class="login-wrap"> 
        <p class="login-img"><i class="icon_lock_alt"></i></p> 
        <p style="color: darkred; font-weight: bold;"><?php echo $error; ?></p> 
        <div class="input-group"> 
          <span class="input-group-addon"><i class="icon_profile"></i></span> 
          <input type="text" class="form-control" name="u" placeholder="Username" autofocus required> 
        </div> 
        <div class="input-group"> 
          <span class="input-group-addon"><i class="icon_key_alt"></i></span> 
          <input type="password" class="form-control" name="p" placeholder="Password" required> 
        </div> 
        <button class="btn btn-primary btn-lg btn-block" name="log" type="submit" style="background-color: orange; border: none; padding: 10px;">Login</button> 
      </div> 
    </form> 
    <p style="text-align: center; font-size: 12px; color: #999;">Please keep your login details safe and secure.</p> 
  </div> 
  <footer style="background-color: #23233f; color: #fff; text-align: center; position: fixed; bottom: 0; width: 100%; padding: 10px;"> 
    <p>&copy; 2023 Newage Union Bank. All rights reserved.</p> 
    <p>Warning: Unauthorized access is prohibited. All activities are monitored and recorded.</p> 
  </footer> 
</body>
</html>
