<?php
include 'include/config.php';

if(!empty($_POST["username"])) {
  $query = "SELECT * FROM schools WHERE username='" . $_POST["username"] . "'";
  $result = mysqli_query($conn,$query);
  $count = mysqli_num_rows($result);
  if($count>0) {
    echo "<span style='color:red'> Sorry Username already exists .</span>";
    echo "<script>$('#submit').prop('disabled',true);</script>";
  }else{
    // echo "<span style='color:green'> User available for Registration .</span>";
    echo "<script>$('#submit').prop('disabled',false);</script>";
  }
}

if(!empty($_POST["checkschooll"])) {
  $queryy = "SELECT * FROM schools WHERE school_name='" . $_POST["checkschooll"] . "'";
  $resultt = mysqli_query($conn,$queryy);
  $countt = mysqli_num_rows($resultt);
  if($countt>0) {
    echo "<span style='color:red'> Sorry School already exists .</span>";
    echo "<script>$('#submit').prop('disabled',true);</script>";
  }else{
    // echo "<span style='color:green'> User available for Registration .</span>";
    echo "<script>$('#submit').prop('disabled',false);</script>";
  }
}

if(!empty($_POST["checkmobilel"])) {
  $queryyy = "SELECT * FROM user WHERE a_c_number='" . $_POST["checkmobilel"] . "'";
  $resulttt = mysqli_query($conn,$queryyy);
  $counttt = mysqli_num_rows($resulttt);
  if($counttt>0) {
    echo "<span style='color:red'> Sorry Account Number already exists .</span>";
    echo "<script>$('#submit').prop('disabled',true);</script>";
  }else{
    // echo "<span style='color:green'> User available for Registration .</span>";
    echo "<script>$('#submit').prop('disabled',false);</script>";
  }
}


if(!empty($_POST["mobile"])) {
    $query1 = "SELECT * FROM users WHERE user_id='" . $_POST["mobile"] . "'";
    $result1 = mysqli_query($conn,$query1);
    $count1 = mysqli_num_rows($result1);
    if($count1>0) {
      echo "<span style='color:red'> Sorry User Id already exists .</span>";
      echo "<script>$('#submit').prop('disabled',true);</script>";
    }else{
    //   echo "<span style='color:green'> name available for Registration .</span>";
      echo "<script>$('#submit').prop('disabled',false);</script>";
    }
  }
  
  if(!empty($_POST["mobilee"])) {
    $query1 = "SELECT * FROM users WHERE user_id='" . $_POST["mobilee"] . "'";
    $result1 = mysqli_query($conn,$query1);
    $count1 = mysqli_num_rows($result1);
    if($count1>0) {
      echo "<span style='color:red'> Sorry User Id already exists .</span>";
      echo "<script>$('#submit').prop('disabled',true);</script>";
    }else{
    //   echo "<span style='color:green'> name available for Registration .</span>";
      echo "<script>$('#submit').prop('disabled',false);</script>";
    }
  }

?>