I have this php code where it checks if the client_number or client_email present in the database. If present it'll disable the submit button. But when one of the field data is not present in database it enables the button which it shouldn't.
function checkDataExistence($connection){
if(!empty($_POST["clientEmailID"])) {
$query = "SELECT * FROM clients_table WHERE client_email='" . $_POST["clientEmailID"] . "'";
$result = mysqli_query($connection, $query);
$count = mysqli_num_rows($result);
if($count>0) {
echo "<span style='color:red'> This Email is already registered!.</span>";
echo "<script>$('#submit').prop('disabled',true);</script>";
} else{
echo "<script>$('#submit').prop('disabled',false);</script>";
}
}
if(!empty($_POST["clientPhoneNumber"])) {
$query = "SELECT * FROM clients_table WHERE client_phone_number='" . $_POST["clientPhoneNumber"] . "'";
$result = mysqli_query($connection, $query);
$count = mysqli_num_rows($result);
if($count>0) {
echo "<span style='color:red'> This Phone number is already registered.</span>";
echo "<script>$('#submit').prop('disabled',true);</script>";
}else{
echo "<script>$('#submit').prop('disabled',false);</script>";
}
}
}
How to make it work for both input fields?