7.6. Handling Entry Deletion

You've almost completed your administrative controls. All that's left is to add the ability to delete entries. This is fairly straightforward, due to the way that you've constructed the delete link.

The link passes delete as $_GET['page'], so it's easy to identify entries marked for deletion. In admin.php, you check whether $_GET['page'] == 'delete', then pass the entry URL to be deleted to a function called confirmDelete()—you'll write this function in the next section. This function asks the user to confirm that she does in fact wish to delete the entry.

Do this by adding the following code in bold to admin.php:

<?php /* * Include the necessary files */ include_once 'inc/functions.inc.php'; include_once 'inc/db.inc.php'; ...

Get PHP for Absolute Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.