<?php 
include('../include/connection.php');
include('../include/app_config.php');
require_once '../lib/dbconfig.php';
//$user->register("admin", "ndphc@123", "ndphc@123", 1, SUPER_ADMIN_USER_KEY, "Admin", "");
if($user->is_loggedin())
{
    if($_SESSION['user_role']==SUPER_ADMIN_USER_KEY)
     {
         echo '<script>window.location="'.SUPER_ADMIN_LANDING_PAGE.'"</script>';
     }
}

if(isset($_POST['login']))
{
 $umail = $_POST['username'];
 $upass = $_POST['password'];
  
 if($user->login($umail,$upass))
 {
     echo '<script>window.location="index.php"</script>';
     /*else if($_SESSION['user_key']==VENDOR_USER_KEY) 
     {
         //put log activity later (viewers will be able to view, delete log under security)
         echo '<script>window.location="'.VENDOR_LANDING_PAGE.'"</script>';
     }
     else if($_SESSION['user_key']==CUSTOMER_USER_KEY)
     {
         //put log activity later (viewers will be able to view, delete log under security)
         echo '<script>window.location="'.CUSTOMER_LANDING_PAGE.'"</script>';
     }*/
     
 }
 else
 {
     foreach($user->errormsg as $error)
     {
         echo "<p class='text-danger'>".$error."</p>";
     }
 } 
}
?>