Creating the Record Deletion Mechanism

The record deletion mechanism is virtually identical to the script used to view a record. In fact, you can just take the first 44 lines of Listing 19.3 and paste them into a new file, called delentry.php, and make the following changes:

In lines 7, 37, and 43, change "view" to "delete"

In lines 24 and 39, change "View" to "Delete"

Starting with a new line 45, the remainder of the code for delentry.php is shown in Listing 19.4.

Listing 19.4. Script Called delentry.php for Selecting and Deleting a Record

Picking up with line 45, the script looks for the required field, $_POST[sel_id], just as it did in the selentry.php script. If that required value does not exist, the user is redirected to the selection form. In lines 5268, queries delete all information related to the selected individual, from all tables. Lines 7072 place a nice message in $display_block, and the script exits and prints the HTML to the screen. An output of the record deletion script is shown in Figure 19.6.

Figure 19.6. Deleting a record.

When you go back to the record selection form after deleting a record, you'll note that the individual you deleted is no longer in the selection menuas it should be!