I dont know whats wrong with my code but i have this error Notice: Undefined index: delete
I want to make delete function with CRUD
here is my php code:
    if($_POST["delete"])
{
    $query = '
    DELETE FROM `users` WHERE id = :id
    ';
    $statement = $connect->prepare($query);
    $statement->execute(
        array(
            ':id'              => $_POST['id']
        )
    );
    $result = $statement->fetchAll();
    if(isset($result))
    {
        echo '<div class="alert alert-fill-danger" role="alert">User Deleted!<div>';
    }
}
and here is the AJAX function
$(document).on('click', '#delete', function(){
       var id = $(this).data('id');
       $('#message').html('');
       Swal.fire({
  title: 'Are you sure?',
  text: "You want to delete this user?",
  type: 'warning',
  showCancelButton: true,
  confirmButtonColor: '#3085d6',
  cancelButtonColor: '#d33',
  confirmButtonText: 'Yes'
  }).then((result) => {
       if (result.value){
        $.ajax({
         url:'/auth/action',
         method:'POST',
         data:{id:id},
         success:function(data)
         {
          if(data != '')
          {
           load_user_data();
           $('#message').html(data);
          }
         }
        });
                      Swal.fire(
      'User Deleted!',
      '',
      'success'
    )
       }
       })
      });
I dont know what i missed here but the function in php is not working??
 
    