Search⌘ K
AI Features

Deleting Tours: Implementing Soft-Deletion

Explore how to implement a soft-deletion system in a PHP CRUD application by creating forms for deletions, handling POST requests, and marking tours as deleted instead of removing them. Learn to update the tours list dynamically and maintain database integrity while offering user-friendly data management.

Creating a form for deleting tours

We are done with the create, update, and list part. One of the problems is that the list of tours will keep growing forever. There is no way to delete tours, except by manually removing them from our “database”. This is actually a more common solution than you might think. But in our case, we would like to offer a more user-friendly solution: a “Delete” action next to the “Edit” link we already have.

It shouldn’t be a link, though, because a link produces a GET request. A GET request is supposed to be a safe request that won’t produce any side-effects. It will only show data, not change it. When you want to do a delete operation, you should therefore do that with a POST request. A link can’t let the browser make a POST request, but a form ...