Deleting a Record

Having loaded up the various possible variables that could have been posted with any values that were passed, the program then checks whether the variable $_POST[‘delete’] has a value. If so, the user has clicked on a DELETE RECORD button to erase a record. In this case, the value of $isbn will also have been posted. As you’ll recall, the ISBN uniquely identifies each record. The HTML form appends the ISBN to the DELETE FROM query string created in the variable $query, which is then passed to the mysql_query function to issue it to MySQL. mysql_query returns either
TRUE or FALSE, and FALSE causes an error message to be displayed explaining what went wrong.
 
If $delete didn’t contain the word “yes,” then the following else statement is executed. $query is set to an INSERT INTO command, followed by the five values to be inserted. The variable is then passed to mysql_query, which upon completion returns eitherTRUE or FALSE. If FALSE is returned, an error message is displayed.