This is my code when I want to add an operation, but it doesn't check for an existing operation that is already in the database, is there any way to do so? code below:
<?php
include('db_conn.php');
$operationname = $_POST['operationname'];
$cost = $_POST['cost'];
$sql = "INSERT INTO operation(operationname,cost) VALUES('$operationname', '$cost')";
$query = mysqli_query($con, $sql);
if($query==true){
$data = array(
'status'=>'success',
);
echo json_encode($data);
} else {
$data = array(
'status'=>'failed',
);
echo json_encode($data);
}
?>