<?php //GET AN INSTANCE OF GBXML $data_type = 'messages'; $record_delim = 'message'; $filename = '../data/data.xml'; $gbXML = new gbXML($data_type, $record_delim, $filename); // Validate browser input ------------------------------------------------------------ $id = isset($_GET['id']) ? $_GET['id'] : FALSE; $order = isset($_GET['order']) ? $_GET['order'] : FALSE; $error = FALSE; if (!is_numeric($id)) { $error = TRUE; $errorMsg = 'The ID provided is not a number.'; } else { if (!$gbXML->tag_and_value_exist('id', $id)) { $error = TRUE; $errorMsg = 'The ID provided does not match any record in the GuestBook.'; } } //REMOVE THE RECORD FROM THE DATA.XML FILE //If we fail, set the error flag if ($gbXML->delete_record_from_file($id) === FALSE) { $error = TRUE; $errorMsg = 'An unknown error occurred: the guest book record could not be deleted.'; } if ($error === TRUE) { echo <<<HTML \t<p class="error">{$errorMsg}</p> <p><a href="modify.php">Back to Delete Menu</a></p> <p>
<p class="error">The id supplied is not a number. Please try again.</p> <p><a href="javascript: history.go(-1);">Go back</a></p> HTML; include '../includes/admin_footer.php'; exit; } //Instantiate a gbXML object to work with the guestbook entries $data_type = 'messages'; $record_delim = 'message'; $filename = '../data/data.xml'; $mygbXML = new gbXML($data_type, $record_delim, $filename); //Check that the id we are trying to edit actually exists $tag_name = 'id'; $tag_value = $_GET['id']; if (!$mygbXML->tag_and_value_exist($tag_name, $tag_value)) { echo <<<HTML <p class="error">The id supplied does not exist in the guest book. Please try again.</p> <p><a href="javascript: history.go(-1);">Go back</a></p> HTML; include '../includes/admin_footer.php'; exit; } //go to the guestbook and get the ID requested to edit if (!($recordArray = $mygbXML->get_record_from_file($_GET['id']))) { echo <<<HTML <p class="error">An unknown error occured. The record could not be read from the data file.</p> <p><a href="javascript: history.go(-1);">Go Back</a></p> HTML;