<?php
ob_start();   
session_start();
include ('connection.php') ;

  if($_SERVER['REQUEST_METHOD'] == "POST") {
    //mysql_connect("connection.php", "username", "password");
    //@mysql_select_db("database") or die( "Unable to connect to database");
    $username = mysqli_real_escape_string($conn,$_POST['username']);
    $password = mysqli_real_escape_string($conn,$_POST['password']);
    $result = mysqli_query($conn,"SELECT * FROM users WHERE username='$username' AND password='$password'");
	
    if(mysqli_num_rows($result) > 0) {
      $_SESSION['is_logged_in'] = 1;
	  
	   $LOGIN_NAME = $_POST['username'];
	  $EMPLOYEE_PASSWORD = $_POST['password'];
	  
	  $_SESSION["LOGIN_NAME"] = $LOGIN_NAME;
	  $_SESSION["EMPLOYEE_PASSWORD"] = $EMPLOYEE_PASSWORD;
    }
  }

  if(!isset($_SESSION['is_logged_in'])) {
    header("location:login.php");
  } else {
    header("location:index.php");
  }
  
?>







