<?php
include_once 'shikanisha.kts.php';

// Get the data from the AJAX request
$name = $_POST['tablename'];


// Check if client already exists
$sql_check = "SELECT * FROM tables WHERE table_name = '$name'";
$result = $conn->query($sql_check);

if ($result->num_rows > 0) {
  // Client already exists
  echo "Table with name $name already exists.";
} else {
  // Insert the data into the database
  $sql_insert = "INSERT INTO tables (table_name)
  VALUES ('$name')";
  
  if ($conn->query($sql_insert) === TRUE) {
    // Successfully inserted new client
    echo "Table with name $name has been added Successfully.";
  } else {
    // Error inserting new client
    echo "Error: " . $sql_insert . "<br>" . $conn->error;
  }
}

?>
