<?php
   include('connect.php');
   include('logging.php');


if ($_SERVER["REQUEST_METHOD"] == "POST") {

  if (isset($_POST['existboolean'])) {

    $existboolean = mysqli_real_escape_string($db,$_POST['existboolean']);
    $companyName = mysqli_real_escape_string($db,$_POST['companyName']);
    $companyBRN = mysqli_real_escape_string($db,$_POST['companyBRN']);


    if ($existboolean == "new") {
      $sqlCreateCompany = "INSERT INTO companyfile (
      companyName,
      companyBRN
      ) VALUES (
      '$companyName',
      '$companyBRN');";

    } else {
    }

      if(mysqli_query($db, $sqlCreateCompany)) {

      $employeeUpdate = "User created new company file. ";

      logEvent($db,"Company File Added",$employeeUpdate,$last_id);
      
      header("location: index.php?updated=2");

       } else {
         echo "Error: " . mysqli_error($db);
    }

    } else {
    echo "Error 101111!!!";
   }
 
}

?>