Enhancing Websites with PHP

Delete Database Records

You now know how to insert database records using a combination of PHP and the SQL insert query. There will be occasions, however when you want to delete a guest whose data is no longer current or for one who has submitted an inappropriate comment. Deleting database records is a relatively straightforward process of passing the guestid value to your script using a hidden form element and using the delete SQL query with the where clause (e.g. where the value in the form equals the value stored in the database).

Hidden form elements are commonly used to hide the data being processed from the user because it passes the value to the script behind the scenes (e.g. it is not shown in the browser). As is true with all form elements, the key is in making sure you name the element appropriately remembering that all names should be treated as case-sensitive.