<?php
session_start();
error_reporting(E_ALL);
ini_set('display_errors', 1);

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Database connection
    include('connection.php');

    $username = $_POST["username"];


    $password = $_POST["password"];
  
    // Prepare and execute the SQL query to retrieve the employee_id
    $sql = "SELECT employee_id FROM add_employee WHERE employee_id = '$username' AND password = '$password'";
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        // User found, get the employee_id
        $row = $result->fetch_assoc();
        $_SESSION["emp_id"] = $row['employee_id'];

        // Create a session with the employee_id
        // $_SESSION["employee_id"] =/ $employee_id;

        
        // Redirect to the dashboard page
        header("Location: index.php?success=Login Successfully!!!");
        exit();
    } else {
        echo "Invalid username or password.";
    }

    $conn->close();
}
?>