print_r($_POST); echo "<br><br>"; // 4. NOTICE the new line below. This is checking to see // if this page was submitted to itself, or if we // came from the guestbook_delete form. // If the page was submitted to itself, the // checkbox named confirm_delete // will have a value. We only want to run // the code below if it does *not* have a value. if (!isset($_POST["confirm_delete"])) { // Run only if coming from the current page // 5. Enter a foreach loop here to run the check_submitted() and sanitize() functions on every field that was submitted. // HINT: This is 4 lines of code (including the ending curly brace). // It is the same as in the guestbook_add_action file, Step 4. foreach ($form_fields as $key => $value) { check_submitted($key, $value, $missing_count); sanitize($key, $value, $_POST[$key]); } // exit if missing data in any but checkboxes if ($missing_count > 0) { echo "<br />Please <a href='guestbook_delete.php'>Go Back</a> and fill in the missing data.<br /><br /></div></body></html>"; exit; } // ASSIGN DATA TO VARIABLES FOR EASIER HANDLING $id = $_POST['id']; // CONNECT TO DATABASE (Step 1) // 6. Insert an include for connection.php, using include_once. include_once "includes/connection.php"; // SQL STATEMENT: Find record that is about to be deleted // 7. Create an SQL statement that selects all of the records from the guestbook table // where guestbook.id=$id .
<?php include_once "includes/html_header.php"; ?> <!-- ====================================== --> <!-- The line below is a class that I created to mimic the action of the 'blockquote' tag in HTML, which is now deprecated. --> <div class="blockquote"> <?php // FUNCTION CALLS // -- CHECK EACH FIELD FOR MISSING DATA check_submitted("name", "text", $missing_count); check_submitted("email", "text", $missing_count); check_submitted("comment", "textarea", $missing_count); check_submitted("mail", "checkbox", $missing_count); // 4a. Enter your function call for count_errors below this comment. There should be only one line of code. count_errors($missing_count); // Below this point is your our old code for checking for missing data. // Notice that you had more code, and it did less -- it didn't track how many fields were missing. // Once you create the functions and call them, please delete the $counter line and the 'if' blocks in this section. // -- SANITIZE FIELDS (REMOVE DANGEROUS CHARACTERS) -- text boxes and textarea only sanitize("name", "text", $_POST["name"]); sanitize("email", "text", $_POST["email"]); sanitize("comment", "textarea", $_POST["comment"]); // Below this point is your our old code for checking for sanitizing the data. // Notice that you had a lot more code, and it did less -- we didn't escape quote marks in the previous version. // Once you create the functions and call them, please delete the old code in this section. // -- DISPLAY OUTPUT echo "<h3><i>You submitted the following information:</i></h3>"; echo "<div id='formData'>";