<?php
include "connect.php";

if(isset($_POST['username'])){
   $username = $_POST['username'];

   $query = "select count(*) as cntUser from users where username='".$username."'";

   $result = mysqli_query($db,$query);
   
   if(mysqli_num_rows($result)){
      $row = mysqli_fetch_array($result);

      $count = $row['cntUser'];
    
      if($count == 0){
          //$response = "<input type=\"button\" name=\"save\" class=\"btn btn-primary\" value=\"Add User\" id=\"butsaveNU\">";
         $response = "OK";
      } else {
         //$response = "<span style='color: red;'>User already exists!</span>";
         $response = "KO";
      }
   
   }

   echo $response;
   die;
}