<?php
session_start();
if(!isset($_SESSION['username']) || !isset($_SESSION['password'])){
 header("Location: index.php");
} 
 //include 'logoff.html';
?>
<?php
$link = mysqli_connect("localhost", "comeadve_glory1", "Safari#@2027$", "comeadve_tdmc");

    if($link === false){

        die("ERROR: Could not connect. " . mysqli_connect_error());

    }
    // Escape user inputs for security
	
	$idNumber = mysqli_real_escape_string($link, $_POST['IDNumber']);
	//$idNumber="134000/22";

    $fullName = mysqli_real_escape_string($link, $_POST['Name']);

    $phone = mysqli_real_escape_string($link, $_POST['Phone']);


    // attempt insert query execution

    $sql = "INSERT INTO waiters (Id, IDNumber, Name, Phone, Status) VALUES ('Null','$idNumber', '$fullName', '$phone','0')";
	//$sql2 = INSERT INTO `comeadve_tdmc`.`employees` (`Id`, `IDNumber`, `Name`, `Phone`, `Status`) VALUES (NULL, '134000/12', 'James Mongi', '0989897878', '0');

    if(mysqli_query($link, $sql)){

        $msgw = "Records added successfully.";
        header("location:addporters.php?msgw=$msgw");

    } else{

        $msgw = "Data was not added, Account number already exist.";
        header("location:addporters.php?msgw=$msgw");

    }

    mysqli_close($link);

    ?>