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

$name=$_GET['name'];
$pettype=$_GET['pettype'];
$userid=$_GET['userid'];

 $resultdata = $con->query("select * from `myAnimal` where name='$name' AND animalId='$pettype' AND userId='$userid'");

while($row = mysqli_fetch_array($resultdata)){
    $id=$row['id'];
   
}
if($id > 0)
{ 
$j->status  = "105";
$j->message = "Animal Already Add";   
}
else{
    

$insert = $con->query("INSERT INTO `myAnimal`(`animalId`, `name`, `userId`) VALUES('$pettype','$name','$userid')");
if($insert > 0){
    
$j->status  = "101";
$j->message = "Animal Added Successfully";

}
else{
$j->status  = "104";
$j->message = "Some thing wrong";
}

}
echo json_encode($j); 
?>