<?php
ob_start("ob_gzhandler");
//error_reporting(0);
error_reporting(E_ALL  & ~E_DEPRECATED);
ini_set('display_errors', -1);
include_once '../includes/db.php';
include_once 'includes/AdminUser.php';
session_start();
$session_uid = isset($_SESSION['admin_id']) ? $_SESSION['admin_id'] : NULL; 
if(!empty($session_uid)) {
    header("location:dashboard.php");
  }
$AdminUser = new AdminUser();
//Login
$login_error='';
if(!empty($_POST['username_admin']) && !empty($_POST['password_admin'])) {
   $username=$_POST['username_admin'];
   $password=$_POST['password_admin'];
    if (strlen($username)>0 && strlen($password)>0) {
        $login=$AdminUser->User_Login($username,$password);
        if($login) {
           $_SESSION['admin_id']=$login;
           $url=$admin_base_url.'dashboard.php';
           header("Location:$url");
         } else {
           $login_error="<span class='error'>Username or Password is invalid</span>";
         }
      }
 }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>SocialMatv1.0 || Admin Login</title>
<link rel="stylesheet" type="text/css" href="<?php echo $base_url; ?>smadmin/css/style.css" />
</head>

<body>
<div class="header"></div>
<div class="login_wrp">
   <div class="logo"><span class="helper"></span><img src="admin_img/admin_logo.png" /></div>
   <form role="form" autocomplete="off" method="post" action="">
   <div class="login_info">
   <div class="mat-in">
        <input type="text" name="username_admin" value="" required></input>
        <span class="bar"></span>
        <label>Username</label>
      </div>
      <div class="mat-in">
        <input type="password" name="password_admin" value="" required></input>
        <span class="bar"></span>
        <label>Password</label>
      </div>
      <?php echo $login_error;?>
      <div class="loginbtn"><input type="submit" class="login_btn" id="login" value="LOGIN" /></div>
   </div>
   </form>
</div>
</body>
</html>